[Home] [By Thread] [By Date] [Recent Entries]
Hi Virginia,
That is an FAQ. Whether you use XSLT 1.0 or 2.0, you can use the document(...) function to process an external xml document (we reserve the term "import" usually for xsl files imported with xsl:import) just the way you would process any other node. I.e.: <xsl:apply-templates select="document(....)/document" /> Then, secondly, you need to have modified copy template (copy-of makes a deep-copy and does not give you the option to modify its children, use xsl:copy instead), like this: <xsl:template match="document">
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:copy>
</xsl:template><xsl:template match="*">
<!-- create element with new prefix/namespace -->
<xsl:element name="xed:{local-name()}" >
<!-- copy attributes, if any -->
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:element>
</xsl:template><!-- non-element nodes --> <xsl:template match="node()"> <xsl:copy-of select="." /> </xsl:template> Thirdly, you must make sure that the xed: prefix exists in the xsl:stylesheet declaration. In XSLT 2.0, you can also use the following, perhaps more clearer syntax: <xsl:element name="{local-name()}" namespace="http://mynamespace"> Note that you seem to request a certain prefix, "xed:", but that in XML the prefix does not matter, only the namespace that the prefix is bound to matters. HTH, Cheers, Abel Braaksma PS: if you process several documents from external sources and you also process a main document, you'd be safest to switch to a different mode when processing your external docs, i.e.: <xsl:apply-template select="document(....)/document" mode="external-doc" /> and <xsl:template match="...." mode="external-doc"> ... </ La RKO wrote: Suppose that I want to import a xml file into another
|

Cart



