Subject: Re: [xsl] Problem using Key on multiple elements From: Sreenath Juluri <jssreenath@xxxxxxxxx> Date: Tue, 16 Aug 2005 13:28:45 +0530 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Problem using Key on mult, Joris Gillis | Thread | [xsl] Breaking from the loop (for-e, Oleg Konovalov |
Re: [xsl] xsl:number on attribute n, Jack Matheson | Date | Re: [xsl] How recursively iterate o, Dimitre Novatchev |
Month |