danka_6786978 (7/24/2013)
Hi, I am upgrading reports from 2005 to 2008R2 and I noticed that two reports are failing on the new server. So, after looking up its issue, I realized that I might need to rewrite XSL that was formatting the XML output/render...So, my scenario is as such:
the report renders xml with root node <Report blah blah bla> and then it renders my xml, with its own root like I need it. So it's kinda double wrapped, it's still full and proper xml after the render.
I got to the point where I get <?xml version="1.0"?> at the top of the rendered file, and then I have that <Report blah name blah> root that I have to remove... It's pretty confusing, spent all day searching for an answer.
How do I go about removing the first line and the <Report....> root from final rendered results?
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" encoding="ascii" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
I'd appreciate some help here.
I know I am a little late here but... You were close, you just needed to change the context in you template match statement to begin at Report.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" encoding="ascii" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="Report/@* | Report/node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
-- Itzik Ben-Gan 2001