Using XSLT, I'm wondering how to get the output to use my stylesheet's namespace prefixes rather than the input document's prefixes. By way of example, given this very simplified document:
<?xml version="1.0"?>
<a:node xmlns:a="urn:schemas:blah:"/>
And the following XSL transform:
<?xml version="1.0"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:blah="urn:schemas:blah:" version="2.0">
<xsl:output indent="yes">
<xsl:template match="/blah:node">
<xsl:copy/><!-- marked -->
</xsl:template>
</xsl:transform>
I can tell that the processor (Saxon8 if it matters) recognizes the equivalence of the prefixes 'blah:' and 'a:', but fn:in-scope-prefixes() for example doesn't show 'blah', only 'a'. Changing the <!-- marked -->
line above to:
<node><xsl:value-of select="in-scope-prefixes(.)"/></node>
Outputs:
<?xml version="1.0" encoding="UTF-8"?>
<node xmlns:blah="urn:schemas:blah:">xml a</node>
How can I map the input prefix 'a' to 'blah' without knowing in advance that the input file calls that prefix 'a'? (So <xsl:namespace-alias/>
won't work for me.)
As further context, if it points toward a better solution, this is for viewing XML documents that are generated externally. The external process creates the input document using automatically-generated prefixes 'a:', 'b:', 'c:', etc. I want to be able to display those prefixes using 'friendlier' namespace prefixes.
Update: The in-scope-prefixes() behavior is explained by the definition of Statically known namespaces