2016-08-25 67 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

即使我在裏面有一些標籤,我可以得到這些值。但我無法獲得

標記中的任何屬性的值。 –