2011-03-09 75 views
0

我正在處理從ArgoUML導出的XMI文檔。它有本地XML命名空間定義沒有按預期工作

<UML:DataType href='http://argouml.org/profiles/uml14/default-uml14.xmi#-84-17--56-5-43645a83:11466542d86:-8000:000000000000087C'/>

指向我已經宣佈的xmlns形式

<UML:DataType xmi.id="-84-17--56-5-43645a83:11466542d86:-8000:000000000000087C" 
       name="Integer" 
       isSpecification="false" 
       isRoot="false" 
       isLeaf="false" 
       isAbstract="false"/> 

的項目形式元素:UML =「org.omg.xmi。 namespace.UML「放在xslt文件的頂部。我想我應該可以使用像這樣的東西:

<xsl:variable name="typeref" select="@href"/> 
<xsl:variable name="ns" select='substring-before($typeref, "#")'/> 
<xsl:variable name="identifier" select='substring-after($typeref, "#")'/> 
<xsl:value-of xmlns:UML="$ns" 
       select='//UML:DataType[@xmi.id="$identifier"]/@name'/> 

推斷,我的UML屬性類型是整數,但是這給了我

SystemId Unknown; Line #136; Column #94; A location step was expected following the '/' or '//' token.

如果我改變的xmlns爲AAA,然後我沒有錯誤,只是一個空標籤。我在Debian上使用Xalan2。我錯過了什麼?

+1

我沒有看到語法錯誤。但它看起來像你正試圖用'xmlns:UML =「$ ns」'做一個動態命名空間聲明。爲什麼?此外,這不是可能的,我不認爲對你的情況有用。 – 2011-03-09 23:47:44

+0

我同意以前的答案,xmlns的(無效)名稱空間前綴規範的建議目的是什麼:UML =「$ ns」? – 2011-03-10 02:17:55

回答

0

別介意我。只是犯了混淆命名空間和URI的經典錯誤。我真的需要的是< xsl:value = of select ='document($ ns)// UML:DataType [@ xmi.id = $ identifier]/@ name'/ >