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