2016-08-25 40 views
1
<xoe:documents xmlns:xoe="http://xxxxxx" count="1"> 

    <xocs:doc xmlns:xocs="xxxxxx" xmlns:xsi="yyyyyyy" xsi:schemaLocation="zzzzzz"> 

    <xocs:meta>...</xocs:meta> 

    <xocs:serial-item> 
     <!-- this line --> 
     <article xmlns:sa="www.google.hgy" xmlns="http://www.xyzq1.org/xml/ja/dtd" version="5.4" xml:lang="pl" docsubtype="rev"> 
     <article-info> 
     </article-info> 
     </article> 

    </xocs:serial-item> 

    </xocs:doc> 

</xoe:documents> 

我无法获得'xml:lang'属性的值。甚至认为我与下面的XPath无法获得'xml:lang'属性的值

<xsl:variable name="rootPath" select="/xoe:documents/xocs:doc/xocs:serial-item"/> 
<xsl:variable name="lang" select="$rootPath/ja:article[@xml:lang]"/> 
or 
<xsl:variable name="lang" select="$rootPath/ja:article/@xml:lang"/> 

这里试图JA是我的XSLT代码

xmlns:ja="http://www.xyzq1.org/xml/ja/dtd" 

有人能帮帮已经定义?

+0

在您的示例XML中,“article”位于“www.yahoo.mkt”命名空间中,而不是“http:// www.xyzq1.org/xml/ja/dtd”。 – JLRishe

+0

谢谢,我改变了。仍然没有结果。 –

回答

0

首先,你需要声明这些:

xmlns:xoe="http://xxxxxx" 
xmlns:xocs="xxxxxx" 
xmlns:ya="www.yahoo.mkt" 

然后你就可以使用得到xml:lang属性的值:

<xsl:value-of select="/xoe:documents/xocs:doc/xocs:serial-item/ya:article/@xml:lang"/> 

注意,在样式表中的命名空间声明中的URI必须与源XML中出现的URI相同。前缀可以是任何你喜欢的。

+0

是的,我推荐了我的代码中的所有东西。但我仍然无法获得价值。 –

+0

@AJAYKUMAR你可以在这里看到它的工作原理(适应你的修改示例):http://xsltransform.net/94AbWAK –

+0

即使我在里面有一些标签,我可以得到这些值。但我无法获得

标记中的任何属性的值。 –