其實我看,我可以添加名字空間。因爲我非常接近我期望看到的輸出。首先代碼:添加命名空間前綴子節點問題
XML:
<helptext>
<h6>General configuration options.</h6>
<h2>Changing not yet supported.</h2>
<p>this is a <b>paragraph</b><br/>this is a new line</p>
</helptext>
XSL:
<xsl:template name="transformHelptext">
<xsl:for-each select="./child::*">
<xsl:element name="ht:{local-name()}">
<xsl:choose>
<xsl:when test="count(./child::*)>0">
<xsl:call-template name="transformHelptext"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:for-each>
</xsl:template>
到目前爲止好。 <h6>..</h6>
和<h2>...</h2>
行沒有問題。 但第三行有一個子節點,它是一個<b>
。不知何故,「段落」是唯一顯示的文字,對於這一行。我在choose
聲明中有錯誤。但我無法弄清楚。
由於
PS:HT命名空間在XSL樣式表的標記定義和它是 '的xmlns:HT = 「http://www.w3.org/1999/xhtml」'
PS:我嘗試做的是,使之可以應用HTML標籤類似這樣的替代,在我的具體XML節點風格
謝謝您的回覆。但它確實顯示純文本,除非瀏覽器是Firefox。 – savruk 2011-04-19 09:54:49
@savruk也許XML頭缺少 – Stephan 2011-04-19 10:14:12
其實我沒有得到它與您的代碼工作,謝謝 – savruk 2011-04-19 10:15:05