Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2004, 03:56 AM
Authorized User
 
Join Date: Jul 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to NotesSensei Send a message via Yahoo to NotesSensei
Default Use a variable as a part of an XPath?

Hi there,
I'm struggeling with a basic problem. This is my xml:

<Demo>
  <NextDay>
     <German>morgen</German>
     <English>tomorrow</English>
     <Italian>domani</Italian>
  </NextDay>
</Demo>
I would like to extract the value based on a variable (or a parameter to be more precise).

<xsl:variable name="lang" select="'Italian'" />
....
<xsl:template match="NextDay">
  <xsl:parameter name="curLang" />
AND HERE I GOT STUCK: <xsl:value-of select="?????" />
<xsl:template>

I tried $curLang, '$curLang', '{$curLang}', {$curLang}

It's a standard problem, so it looks to me.. replace part of an XPath with a variable name. What am I missing out?

:( stw

If you think education is expensive - try ignorance!
__________________
If you think education is expensive - try ignorance!
 
Old July 7th, 2004, 04:04 AM
Authorized User
 
Join Date: Jul 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi stw,

If your variable is global (defined under xsl:stylesheet), try

<xsl:variable name="lang" select="'Italian'" />

...

<xsl:template match="NextDay">
       <xsl:value-of select="*[name()=$lang]" />
</xsl:template>

Regards
Bryan

 
Old July 7th, 2004, 04:10 AM
Authorized User
 
Join Date: Jul 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to NotesSensei Send a message via Yahoo to NotesSensei
Default

Thx a lot!

the [name()=...] was the missing piece. It's quite mindblowing to understand the difference between text and node
;) stw

If you think education is expensive - try ignorance!





Similar Threads
Thread Thread Starter Forum Replies Last Post
variable to equal part of string melkin Classic ASP Basics 28 May 17th, 2007 01:08 PM
Object variable or With block variable not set haidee_mccaffrey Classic ASP Professional 5 March 8th, 2007 03:34 PM
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
pass java variable to xsl variable kathy1016cats XSLT 1 June 14th, 2006 06:23 PM
"object variable or with block variable not set" netfresher ASP.NET 1.0 and 1.1 Basics 1 June 12th, 2006 03:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.