From inside xslt, can you output all the XML?

Inside my XSLT, which converts the XML order code, I want to dump all the XML I'm working with right now. How can i do this?

I am bridging some XML based HTML and want to dump all the XML into a text box.

+4
source share
4 answers

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> 
+8
source
 <?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> 
+1
source

So, you want to create a <textarea> element and unload everything into this 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 will not be shielded!

Or put <xsl:copy-of> wherever you create the text box.

A quick note, if you need to work with really large XML files: if you call a copy from a template that is somewhere deeper in the hierarchy, this can slow down the xslt processor because it must “jump” outside the local node. Thus, the xslt processor cannot use certain optimizations.

+1
source
 <xsl:copy-of select="."/> 
+1
source

Source: https://habr.com/ru/post/1307175/


All Articles