2012-08-06 34 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> 
相關問題