<xsl:variable name="id">
<idNum>0607V45621014F</idNum>
</xsl:variable>
<xsl:variable name="pathId" select="Orders/Order[ORD_Num='$id/idNum']"/>
....not select the idNum
an o开发者_JAVA技巧ther..not..
<xsl:variable name="XmlFile" select="YG.xml"/>
<xsl:value-of select="document($XmlFile)/aziende/azienda/ragione_sociale"/>
or other...not..
<xsl:variable name="tagName" select="aziende"/>
<xsl:value-of select="document($XmlFile)/$tagName/azienda/ragione_sociale"/>
1)
<xsl:variable name="pathId" select="Orders/Order[ORD_Num='$id/idNum']"/>
You are saying: An Order
element wich has at least one ORD_Num
child with string value equal to '$id/idNum'
.
Replace with:
<xsl:variable name="pathId" select="Orders/Order[ORD_Num=$id]"/>
Because the string value of $id variable (a Result Tree Fragment as you define) is 0607V45621014F
.
Note: It would be better if you define $id as a string like select="'0607V45621014F'"
. Also, you can't (in XSLT 1.0) do: [ORD_Num=$id/idNum]
because /
operator can't be apply to a RTF.
2)
<xsl:variable name="XmlFile" select="YG.xml"/>
<xsl:value-of select="document($XmlFile)/aziende/azienda/ragione_sociale"/>
Here, you are saying: Let be $XmlFile a node set with all YG.xml
elements childs of context node, etc.
Replace (if you want a document with relative uri YG.xml
)
<xsl:variable name="XmlFile" select="'YG.xml'"/>
Note: this does not trought an error because document()
is very versatile (It's the few ones that take an object
as param)
3)
<xsl:variable name="tagName" select="aziende"/>
<xsl:value-of select="document($XmlFile)/$tagName/azienda/ragione_sociale"/>
This does not work because the right expresion of /
must be a path (In XSLT 2.0 can be a function as well).
Replace with:
<xsl:variable name="tagName" select="document($XmlFile)/aziende"/>
<xsl:value-of select="$tagName/azienda/ragione_sociale"/>
Or
<xsl:variable name="tagName" select="'aziende'"/>
<xsl:value-of select="document($XmlFile)/*[name()=$tagName]/azienda/ragione_sociale"/>
精彩评论