I apologize if this has been answered before, I couldn't find it.
I'm trying to transform XML to XML and specify a schema in the output
XML. I am transforming nodes to different local names while keeping
the same namespace. This works fine, until I try to introduce the
schema.
My input looks like this:
<a xmlns="some_url">
<b>doo dah</b>
</a>
I want this output:
<x:c xmlns:x="some_url" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xsi:schemaLocation="some_url myschema.xsd">
<x:d>doo dah</x:d>
</x:c>
Here is a stylesheet that works, but doesn't output the schema
location:
<xsl:stylesheet xmlns:x="some_url" xmlns:placeholder="Placeholder"
version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:namespace-alias stylesheet-prefix="placeholder" result-
prefix="x"/>
<xsl:template match="x:a">
<placeholder:c>
<xsl:apply-templates select="@* | node()"/>
</placeholder:c>
</xsl:template>
<xsl:template match="x:b">
<placeholder:d>
<xsl:apply-templates select="@* | node()"/>
</placeholder:d>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
I'm using XmlSpy 5.0 with microsoft MSXML selected to do my tests.
If I add the schema declaration to the xsl file it refuses to
transform because the root node <xsl:stylesheetisn't in the schema.
I can't figure out how to tell it to output the schema declaration,
but not to validate the input or the stylesheet itself using that
schema.
Any help would be greatly appreciated!