简体   繁体   中英

XSLT How to traverse cdata section that contains xml

input:

<store xmlns="test">
    <item>book</item>
    <info><![CDATA[<?xml version="1.0"?><value xmlns="value">
<price>11</price>
</value>]]>
    </info>
</store>

I want the output like below

<value xmlns="value">
    <item>book</item>
    <price>11</price>
</value>

Can i achieve this?

Can i achieve this?

Not in pure XSLT 1.0 or even XSLT 2.0.

If you wait to have an XSLT 3.0 XSLT processor (still a W3C WD (Working draft)), then you'd be able to use a function called parse-xml() to parse the text node child of info into a separate XML document.

In XSLT 1.0 or 2.0 you need to write an extension function, which when passed a string (like the value of info , parses it as XML and returns the parsed XmlDocument back to the transformation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM