I am using XslCompiledTransform.Load and everytime I get the error message:
'version' cannot be a child of the 'Transformation' element
This is the stylesheet:
<Transformation><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="urn:my-scripts"
xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"><xsl:output
method="xml" /><xsl:template match="node() | @*"><xsl:copy><xsl:apply-templates
select="@* | node()" /></xsl:copy></xsl:template><xsl:template match="testlist"><xsl:copy>
<xsl:apply-templates select="test"><xsl:sort select="requestor/code" /></xsl:apply-
templates></xsl:copy></xsl:template></xsl:stylesheet></Transformation>
If I remove the version i get the error: Missing mandatory attribute 'version' Do I get the error because I am using the stylesheet inside the Tag 'Transformation'?
The answer to your question is "Yes". You do get the error because you have but the xsl:stylesheet
element inside a Transformation
element
<Transformation>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xsl:stylesheet
needs to be the root element, so Transformation
needs to be removed.
Having said that, perhaps you meant to do this....
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl">
<xsl:output method="xml"/>
<xsl:template match="/">
<Transformation>
<xsl:apply-templates select="@* | node()"/>
</Transformation>
</xsl:template>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="testlist">
<xsl:copy>
<xsl:apply-templates select="test">
<xsl:sort select="requestor/code"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>