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

Re: Problem using Key on multiple elements

Subject: Re: Problem using Key on multiple elements
From: Sreenath Juluri <jssreenath@xxxxxxxxx>
Date: Tue, 16 Aug 2005 13:28:45 +0530
xtvd
hi Joris Gillis!

Thnx. It works. but i didnot understand the funda....

What i understand is this. generate-id() will create a unique id based
on the current value of the context node. U suggested doing this

<xsl:for-each select="a:xtvd/a:productionCrew/a:crew/a:member
        [generate-id()=generate-id(key('roleNames',
                concat(a:givenname,'+',a:surname))[1])]
        /a:givenname">

In my source xml a:member has 3 elements role, givenname and surname.
In the abv for-each we are generating an id for a:member(with 3
elements) and comparing the same with the id for 
concat(a:givenname,'+',a:surname) in the key roleNames.
I did not understand how both the ids match? can u plz explain me
this...hopefully this shud explain where i went wrong in my original
approach.

Thnx
Sreenath.


On 8/13/05, Joris Gillis <roac@xxxxxxxxxx> wrote:
> Hi,
> Tempore 15:20:00, die 08/12/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Sreenath Juluri <jssreenath@xxxxxxxxx>:
> 
> > My source xml looks something like this.
> >... Ill-formed XML
> 
> An attempt to construct well-formed XML out of it (please correct the namespace)
> <xtvd xmlns="a">
> <productionCrew>
> <crew program="EP3297910048">
> <member>
>        <role>Actor</role>
>        <givenname>Peter</givenname>
>        <surname>McCauley</surname>
> </member>
> <member>
>        <role>Actor</role>
>        <givenname>Michael</givenname>
>        <surname>Sinelnikoff</surname>
> </member>
> </crew>
> <crew program="EP3556823923">
> <member>
>        <role>Director</role>
>        <givenname>Michael</givenname>
>        <surname>Sinelnikoff</surname>
> </member>
> <member>
>        <role>Actor</role>
>        <givenname>Michael</givenname>
>        <surname>Offer</surname>
> </member>
> <member>
>        <role>Executive Producer</role>
>        <givenname>John</givenname>
>        <surname>Landis</surname>
> </member>
> </crew>
> </productionCrew>
> </xtvd>
> 
> > Now in my transformed xml there should be only one element for each
> > person irrespective of the role. for eg in the above piece of xml
> > there shud b only one element for Michael Sinelnikoff.
> 
> Try using a key like this:
> 
> <xsl:key name="roleNames"
> match="a:xtvd/a:productionCrew/a:crew/a:member"
> use="concat(a:givenname,'+',a:surname)"/>
> 
> and a loop like this:
> <xsl:for-each select="a:xtvd/a:productionCrew/a:crew/a:member
>        [generate-id()=generate-id(key('roleNames',
>                concat(a:givenname,'+',a:surname))[1])]
>        /a:givenname">
> </xsl:for-each>
> 
> regards,
> --
> Joris Gillis (http://users.telenet.be/root-jg/me.html)
> +G ak^heia jai to k\di p\mta bca_moum ap| p\my;

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.