2012-08-06 32 views
0

我想从另一个系统处理一个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> 

使用节点()值我能够标记之前得到节点的值(本文为)但我无法编写一个模板帽子,在标记,过程标记之前处理节点的一部分,然后返回值的其余部分。有什么建议么?

回答

0

你试过了什么?不应该比

更复杂
<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
<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> 
相关问题