[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Using a variable as the xml node - ignore my previ

Subject: Re: Using a variable as the xml node - ignore my previous mail
From: bharathi kongara <bharathikongara@xxxxxxxxx>
Date: Mon, 27 Mar 2006 08:08:13 -0800 (PST)
xsl ignore node
Hi Joe and Michael,

Thanks for your suggestions. The idea 2 suggested by
Joe worked for me. Now I'm wondering about the easier
idea 1 you've talked about where I can search for the
desired node by an attribute instead of the name of
the node itself (provided ofcourse I change my config
file for that). Can you guide me on that?

Thanks,
Bharathi


Date: Fri, 24 Mar 2006 15:21:57 -0000
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx>
Subject: Re:  Using a variable as the xml node -
ignore my 
previous mail
Message-ID:
<BAY106-DAV3E0501E0EA2182B0FD880D9DF0@xxxxxxx>

----- Original Message ----- 
From: "bharathi kongara" <bharathikongara@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Friday, March 24, 2006 2:58 PM
Subject:  Using a variable as the xml node -
ignore my previous 
mail

> Hi everyone,
>
> I've been playing with this problem from yesterday,
> tried all sort of solutions, but no use.
>
> Here is the problem:
>
> In my xsl, I'm referring to a configuration file
which
> is an xml file.
>
> 1000ConfigFile.xml:
>
> <ConfigFile>
> <100Code>Hundred<100Code>
> <200Code>Twohundred</200Code>
> .
> .
> .
> </ConfigFile>
>
> and the xsl file is:
>
> key1 refers to the 1000 in the name of the config
> file.
> key2 refers to the 100 or 200 ... in the nodes in
the
> config file.
> They will come from a stored procedue.
>
> <xsl:variable name="Config"
> select="document(concat(//key1,'Config.xml'))"/>
>
> Now my problem is, I've to refer to the 100 node or
> 200 node etc which depends on the key2.
>
> I'm doing this - define a vraible for refrerring to
> the node based on key2.
>
> <xsl:variable name="loc"
> select="concat('$Config/ConfigFile/',//key2,'Code')"
> />
>
> When I'm referring to the "loc" variable in the xsl
> later as $loc, it is putting in the string
> "$Config/ConfigFile/100Code" instead of substituting
> the value "Hundred" from that node. But it works
when
> I directly use the $Config/ConfigFile/100Code
instead
> of $loc.
>
> Any ideas? Any help is greatly appreciated.
>
> Thanks in Advance,
> Bharathi
>
>
>
Idea 1, change your XML, it is much easier to handle
something like 
this:
<ConfigFile>
<Code key="100">Hundred</Code>
<Code key="00">Two Hundred</Code>
..

If you must stick with what you have then you need to
use XPath like 
the 
following which are not very elegant:
<xsl:variable name="key2" select="path to key2 goes
here"/>
$Config/ConfigFile/*[name() = $key2]

-- 

Joe

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.