Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There isn't a straight-forward way to generate the textual representation of an element inside a comment. </p> <p><strong>Here is a short one, using an inline extension function (in C#):</strong></p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:my="my:my" exclude-result-prefixes="msxsl my"&gt; &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt; &lt;xsl:template match="/*"&gt; &lt;xsl:comment&gt; &lt;xsl:value-of select="my:stringize(someElement)"/&gt; &lt;/xsl:comment&gt; &lt;/xsl:template&gt; &lt;msxsl:script language="c#" implements-prefix="my"&gt; public string stringize(XPathNavigator doc) { return doc.OuterXml; } &lt;/msxsl:script&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>When this transformation is applied (using the .NET XslCompiledTransform XSLT processor) on the following XML document</strong>:</p> <pre><code>&lt;t&gt; &lt;someElement&gt;someValue&lt;/someElement&gt; &lt;/t&gt; </code></pre> <p><strong>the wanted, correct result is produced</strong>:</p> <pre><code>&lt;!--&lt;someElement&gt;someValue&lt;/someElement&gt;--&gt; </code></pre> <p><strong>There are different ways to do the same in pure XSLT</strong> -- see for example the XSLT code of the <strong><a href="http://www.huttar.net/dimitre/XPV/TopXML-XPV.html" rel="nofollow">XPath Visualizer</a></strong> for a good - looking representation of an XML document as Html (an open source product I wrote 12 years ago and which I am not advertizing in any way here)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload