我在理解xslt時遇到了問題。在我的源文檔中,我必須找到<p>
標記的內部文本,其中class屬性等於"deck"
。瞭解xslt處理具有屬性的元素
在我的源XML地方:
<body>
<p class="deck">Text here</p>
... ... cut ... ... ...
在我的XSL文件
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:TimeInc="http://www.timeinc.com/namespaces/PAMTimeInc/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:prism="http://prismstandard.org/namespaces/basic/2.1/"
xmlns:pam="http://prismstandard.org/namespaces/pam/2.1/"
xmlns:pim="http://prismstandard.org/namespaces/pim/2.1/"
xmlns:prl="http://prismstandard.org/namespaces/prl/2.1/">
<xsl:output method="xml" encoding="utf-8" indent="yes" omit-xml-declaration="yes"/>
<Description>
<xsl:choose>
<xsl:when test="//[email protected] != ''">
<xsl:value-of select="//[email protected]"/>
</xsl:when>
<xsl:otherwise>
<xsl:text disable-output-escaping="yes"/>
</xsl:otherwise>
</xsl:choose>
</Description>
... ... cut ... ... ...
它顯然是不正確,因爲我不知道我在做什麼。有沒有一個例子可以說明如何做到這一點或更多地理解它。
非常感謝,最終代碼結束了: <的xsl:for-每個選擇= 「// P [@類= '甲板']」> 的 xsl:for-each> Description> –
stephenbayer
2009-08-18 20:44:44