Inside my XSLT that is transfomign a order XML, I want to dump the entire XML I am currently working with.
Is this possible?
I am weaving some HTML based on XML, and want to dump the entire XML into a textarea.
Inside my XSLT that is transfomign a order XML, I want to dump the entire XML I am currently working with.
Is this possible?
I am weaving some HTML based on XML, and want to dump the entire XML into a textarea.
<?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" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Probably the shortest ... :)
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
So you want to produce a <textarea>
element, and dump everything into that element?
Then you can use something like:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<textarea>
<xsl:copy-of select="/" />
</textarea>
</xsl:template>
</xsl:stylesheet>
Be careful: The output won't be escaped!
Or put the <xsl:copy-of>
wherever you produce the textarea.
Small note, if you have to work on really large XML files: If you call the copy-of from a template that matches somewhere deeper in the hierarchy, this can slow down the xslt processor, because it must "jump" outside of the local node. So, the xslt processor can't use certain optimizations.