xsl-list
[Top] [All Lists]

[xsl] Unescaping CDATA and turning it into a variable?

2019-06-12 09:51:18
Hello List,

Given a node such as this...

<Fragment>
        <![CDATA[This is some <span class="meta" cid="0”>cheese</span> and 
<span class="meta" cid="1”>chocolate</span>!]]>
</Fragment>

If I use disable-output-escaping:

<xsl:value-of disable-output-escaping="yes" select=“Fragment/text()"/>

It renders with the "markup":

I love <span class="meta" cid="0”>cheese</span> and <span class="meta" 
cid="1”>chocolate</span>!</td>

Which is great. Happy.

But I need to target the spans and the span content and use it elsewhere in the 
stylesheet. Is it possible to extract the text with “markup” as a variable or a 
parameter so I can re-use it before rendering?

Ideally I would have something like…

<xsl:variable name="markup">
       <xsl:value-of select="$FRAGMENT" disable-output-escaping="yes" />
 </xsl:variable>

So I could get the text “cheese".
        
<xsl:value-of select=“$markup/span[cid=0]/text()”/>

I hope my question is clear? This is a simplified version of what I am trying 
to do - but I am having great difficulty even with this…

Thanks!




--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>