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

Re: Define a key with cross reference

Subject: Re: Define a key with cross reference
From: "Ranjan K. Baisak" <ranjanbaisak@xxxxxxxxx>
Date: Fri, 21 Jan 2005 09:20:10 -0800 (PST)
key cross reference
>   note that I have assumed ur context node to be B,
My context node is not necessarily B. Due to the
complex structure of my XML document, To access A, I
have to go through B and I have denined some keys
which can give me B(Let say the key is getB-from-C).
SO when I am in loop of getB-from-C, I want to find
all A elements those match id of C.
So I was wondering whether I could able to achive the
indirect cross reference using meunchian search.
I would appreciate if anybody can help give a look
into the problem.

regards,
Ranjan
--- Vasu Chakkera <vasucv@xxxxxxxxxxx> wrote:

> Define key as Follows
> <xsl:key match="/root/A"  name="A-with-B"
> use="property/@id"/>
> (Define key as a child of xsl:stylesheet element )
> 
> 
> and Use the key like
>  <xsl:value-of
> select="key('A-with-B',property/@id)"/>
>   so you send the property Id to the Key and you get
>      "A"  node which
> has the same Property /@id as the one u sent in to
> the key..
>   note that I have assumed ur context node to be B,
> when I used the key in
> the value-of select. make sure you use the right
> path , depending on your
> context node when using the key
> 
>  for example, if your template matches B nodes and
> you use a xsl:for-each
> select = "properties" in this template, then you
> should use  <xsl:value-of
> select="key('A-with-B',@id)"/>
> Just a  note..
> 
> 
> HTH
> Vasu
> 
> 
> 
> 
> ----- Original Message ----- 
> From: "Ranjan K. Baisak" <ranjanbaisak@xxxxxxxxx>
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Friday, January 21, 2005 2:20 PM
> Subject:  Define a key with cross reference
> 
> 
> > I would appreciate if anybody can help me to key
> with
> > cross reference with related elements. The
> structure
> > of my XML is :
> > <root>
> > <A name="A1">
> > <property id="1"/>
> > <property id="2"/>
> > </A>
> > <A name="A2">
> > <property id="1"/>
> > <property id="3"/>
> > </A>
> > <B name="B1">
> > <property id="1"/>
> > <property id="2"/>
> > </B>
> > <B name="B2">
> > <property id="1"/>
> > <property id="3"/>
> > </B>
> > </root>
> > I need to define a key which can give me all <A>
> > elements which are related to <B> related. The
> > relatioship is through id attribute of property.
> > E.g. for <B name="B2"><property id="1"/>, I should
> get
> > <A name="A1">
> > <property id="1"/>
> > </A>
> > <A name="A2">
> > <property id="1"/>
> > </A>.
> >
> > regards,
> > Ranjan
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > The all-new My Yahoo! - Get yours free!
> > http://my.yahoo.com
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

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-2013 All Rights Reserved.