1
我有一個特定的問題,從某些定義了名稱空間前綴的XML中獲取寬度和高度的值。我可以很容易地使用普通的xpath與命名空間「n:」獲得其他值,例如來自RelatedMaterial的SomeText,但無法獲取寬度和高度的值。XSLT從具有名稱空間前綴的標記中獲取值的問題
示例XML:
<Description>
<Information>
<GroupInformation xml:lang="en">
<BasicDescription>
<RelatedMaterial>
<SomeText>Hello</SomeText>
<t:ContentProperties>
<t:ContentAttributes>
<t:Width>555</t:Width>
<t:Height>444</t:Height>
</t:ContentAttributes>
</t:ContentProperties>
</RelatedMaterial>
</BasicDescription>
</GroupInformation>
</Information>
</Description>
下面是從XSLT的提取物:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:n="urn:t:myfoo:2010" xmlns:tva2="urn:t:myfoo:extended:2008"
<xsl:apply-templates select="n:Description/n:Information/n:GroupInformation"/>
<xsl:template match="n:GroupInformation">
<width>
<xsl:value-of select="n:BasicDescription/n:RelatedMaterial/t:ContentProperties/t:ContentAttributes/t:Width"/>
</width>
</xsl:template>
上面XSLT不用於獲取寬度工作。有任何想法嗎?
您輸入的文件是無效的XML。前綴't'沒有被定義。你能澄清一下嗎? – 2010-07-26 12:29:25