Link to home
Start Free TrialLog in
Avatar of Member_2_547613
Member_2_547613Flag for Germany

asked on

XPath trouble with attribute value in a predicate

Hi experts,
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:
<lov>
 <representations>
   <simplified>Chinese simplified</simplified>
   <pinjin>Pinjin</simplified>
   <ipa>Intl. phon. alphabet</ipy>
   <foo>Bar</foo>
 </representations>
</lov>

someplace early in the xslt file I "load" the file
<xsl:variable name="LOV">
  <xsl:copy-of select="document('values_en.xml')//lov" />
</xsl:variable>
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:for-each select="some_element_list">
      <xsl:call-template name="TABLE.TR">
         <xsl:with-param name="Script">
            <xsl:value-of select="$LOV/representations/type/@value" />
         </xsl:with-param>
      </xsl:call-template>
   </xsl:for-each>

Any suggestions?

tia.
CirTap
ASKER CERTIFIED SOLUTION
Avatar of sparkplug
sparkplug

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Member_2_547613

ASKER

Hi,
that worked!
I modified the LOV file a littl so I can use it for other stuff, too

Thanx.

CirTap