Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 在节点中嵌入另一个元素时提取节点的值_Xml_Xslt - Fatal编程技术网

Xml 在节点中嵌入另一个元素时提取节点的值

Xml 在节点中嵌入另一个元素时提取节点的值,xml,xslt,Xml,Xslt,我试图处理来自另一个系统的XML文档,而我得到的XML是伪HTML格式的,我需要将其转换为HTML 示例XML: <DOC> <Paragraph>This text is <bold>bold</bold> and this text is not.</Paragraph> </DOC> <BODY> <P>This text is <b>bold</b> and this

我试图处理来自另一个系统的XML文档,而我得到的XML是伪HTML格式的,我需要将其转换为HTML

示例XML:

<DOC>
<Paragraph>This text is <bold>bold</bold> and this text is not.</Paragraph>
</DOC>
<BODY>
<P>This text is <b>bold</b> and this is not.</P>
</BODY>

此文本为粗体,而此文本为非粗体。
所需输出:

<DOC>
<Paragraph>This text is <bold>bold</bold> and this text is not.</Paragraph>
</DOC>
<BODY>
<P>This text is <b>bold</b> and this is not.</P>
</BODY>

此文本为粗体,此文本为非粗体。


使用node()值,我可以获得标记之前的node的值(此文本为),但我无法编写一个模板来处理标记之前的部分节点,处理标记,然后返回值的其余部分。有什么建议吗?

你尝试了什么?不应该比

<xsl:template match="DOC">
    <BODY><xsl:apply-templates/></BODY>
</xsl:template>

<xsl:template match="Paragraph">
    <P><xsl:apply-templates/></P>
</xsl:template>

<xsl:template match="bold">
    <b><xsl:apply-templates/></b>
</xsl:template>