XSLT;将转义文本解析为节点集并提取子元素 [英] XSLT; parse escaped text to a node-set and extract subelements
问题描述
我一整天都在与这个问题作斗争,但我的智慧快要结束了.
I've been fighting with this problem all day and am just about at my wit's end.
我有一个 XML 文件,其中某些数据部分存储为转义文本,但它们本身是格式良好的 XML.我想将此文本节点中的整个层次结构转换为节点集并提取其中的数据.没有我能想到的变量和函数的组合.
I have an XML file in which certain portions of data are stored as escaped text but are themselves well-formed XML. I want to convert the whole hierarchy in this text node to a node-set and extract the data therein. No combination of variables and functions I can think of works.
我希望它的工作方式是:
The way I'd expect it to work would be:
<xsl:variable name="a" select="InnerXML">
<xsl:for-each select="exsl:node-set($a)/*">
'do something
</xsl:for-each>
输入元素 InnerXML 包含表单的文本
The input element InnerXML contains text of the form
<root><elementa>text</elementa><elementb><elementc/><elementd>text</elementd></elementb></root>
但这并不重要.我只想像普通节点集一样浏览 xml.
but that doesn't really matter. I just want to navigate the xml like a normal node-set.
我哪里出错了?
推荐答案
如果您可以使用 Saxon 9.x,它提供了 saxon:parse() 扩展函数正是为了解决这个任务.
In case you can use Saxon 9.x, it provides the saxon:parse() extension function exactly for solving this task.
这篇关于XSLT;将转义文本解析为节点集并提取子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!