Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

XPath trouble with attribute value in a predicate

Posted on 2003-12-01
2
Medium Priority
?
432 Views
Last Modified: 2013-11-19
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
0
Comment
Question by:cirtap
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
sparkplug earned 2000 total points
ID: 9857031
Hi,

Try the following:

 <xsl:for-each select="some_element_list">
      <xsl:call-template name="TABLE.TR">
         <xsl:with-param name="Script">
            <xsl:value-of select="$LOV/representations/*[name() = current()/@value]" />
         </xsl:with-param>
      </xsl:call-template>
   </xsl:for-each>

"$LOV/representations/*[name() = current()/@value]" selects the node under "representations" with the name equal to the current "value" attribute.

>S'Plug<
0
 
LVL 5

Author Comment

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

Thanx.

CirTap
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question