Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, if I use this stylesheet:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="text"/&gt; &lt;xsl:template match="node/text()"&gt; &lt;xsl:copy/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>on this XML file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;node id=1 text="Book Information" &gt;&lt;![CDATA[This is sample text]]&gt;&lt;/node&gt; </code></pre> <p>I get a parse error, because <code>id=1</code> is invalid XML.</p> <p>Putting quotes around the attribute value (<code>id="1"</code>) and rerunning the stylesheet, I get as output:</p> <blockquote> <p>This is sample text</p> </blockquote> <p>So there's a start. Basically, just treat the CDATA as a text node and you're on your way.</p> <p>You said:</p> <blockquote> <p>I found something like:<br /> <code>&lt;xsl:output cdata-section-elements="text"/&gt;</code><br /> and then to fetch CDATA:<br /> <code>&lt;xsl:value-of select="node" /&gt;</code><br /></p> </blockquote> <p>This approach works just fine if you're using <code>value-of</code> as well. Here would be an example along the lines of your comment, using <code>value-of</code> instead. Note, though, that <code>cdata-section-elements</code> only works on the output side, indicating which <em>output</em> XML elements you want to print as CDATA sections instead of plain old character data. It doesn't have anything to do with <em>fetching</em> the data.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output cdata-section-elements="foo"/&gt; &lt;xsl:template match="/"&gt; &lt;foo&gt; &lt;xsl:value-of select="node"/&gt; &lt;/foo&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>prints out</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;foo&gt;&lt;![CDATA[This is sample text]]&gt;&lt;/foo&gt; </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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