I am trying to process an XML document from another system, and the XML that I am getting is in pseudo-HTML that I need to convert to HTML.
我正在尝试从另一个系统处理XML文档,我得到的XML是伪HTML,我需要转换为HTML。
Sample XML:
示例XML:
<DOC>
<Paragraph>This text is <bold>bold</bold> and this text is not.</Paragraph>
</DOC>
Required Output:
要求输出:
<BODY>
<P>This text is <b>bold</b> and this is not.</P>
</BODY>
Using node() value I am able to get the value of node before tag (This text is ), but I am not able to write a template hat would process part of the node before tag, process tag, and then return to remainder of the value. Any suggestions?
使用node()值我能够在tag(此文本)之前获取node的值,但是我无法编写模板hat将在标记,process标记之前处理节点的一部分,然后返回到剩余的价值。有什么建议么?
2 个解决方案
#1
1
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<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>
#2
0
What did you try? Should not be much more complicated than
你尝试了什么?不应该比复杂得多
<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>
#1
1
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<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>
#2
0
What did you try? Should not be much more complicated than
你尝试了什么?不应该比复杂得多
<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>