XPath trouble with attribute value in a predicate
Posted on 2003-12-01
this is pretty urgent, and I'm running out of ideas.
I'm trying to call a template and pass a parameter based on the content of another node, but I can't figure out how to use an attribute of the context-node as the predicate.
Here are the relevant parts:
values_en.xml with look-up values:
<ipa>Intl. phon. alphabet</ipy>
someplace early in the xslt file I "load" the file
<xsl:copy-of select="document('values_en.xml')//lov" />
I'm not sure if this one would be better -- they both seem to work
<xsl:variable name="LOV" select="document('values_en.xml')//lov" />
In the XML document (call it main.xml) which is actually beeing processed I have some <element type="simplified"> .. <element type="ipa">, with their 'type' attribute matching one of the possible "representations/*" in "values_en.xml" (hope I explained tis well enough)
Now I want to use the value of element/@type, e.g. type="ipa", to find me the matching //lov/representations/ipa element and assign its content for the parameter.
Here's where I loop through some element list of main.xml to create a html table with these "translated" <representations>. Except for the parameter always being empty, everything is doing fine: the template get's called, renders, it knows all the other elements around, but $Script stays void :-(
<xsl:value-of select="$LOV/representations/type/@value" />