Subject: Re: [xsl] Selecting the node which have child without repition From: Brandon Ibach <brandon.ibach@xxxxxxxxxxxxxxxxxxx> Date: Thu, 18 Nov 2010 17:27:05 -0500 |
I see three problems with the current expression, based on your requirements. First, you want to filter out those <b> elements that match preceding <b>s, rather than following <b>s. Second, it only looks at siblings, but the second group of <b>s aren't siblings of the first group. Last, you really only want to filter out a <b> if the preceding <b> that it matches has a <c> child, otherwise it would not have been selected. Given all that, try something like: //b[child::c][not(./@name=(preceding-sibling::b[child::c]/@name | ../preceding-sibling::a/b[child::c]/@name))] -Brandon :) On Thu, Nov 18, 2010 at 12:35 PM, Rashi Bhardwaj <rashi.bhardwaj@xxxxxxxxx> wrote: > Hi all, > > I am facing a problem while selecting a node through xpath....please help me out > > Here is the input xml > > <test> > <a> > <b name ='1'></b> > <b name ='2'></b> > <b name ='3'> > <c></c> > </b> > <b name ='4'> > <c></c> > <c></c> > </b> > </a> > <a> > <b name ='1'></b> > <b name ='2'> > <c></c> > </b> > <b name ='3'></b> > <b name ='4'> > <c></c> > </b> > </a> > </test> > > Xpath: > //b[child::c][not(./@name=following-sibling::b/@name)] > > Output: > b name="3" > b name="4" > b name="2" > b name="4" > > What I want is to select all 'b' that have child 'c', provide the 'b' > with same '@name' which are selected first should not be selected > further. > > Desired output: > > Output: > b name="3" > b name="4" > b name="2" > > As b with @name = 4 has already been searched, it should not come > again in search. > > Please help me .....thanks a lott.... > > Rashi
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Selecting the node which have, Rashi Bhardwaj | Thread | Re: [xsl] Selecting the node which , Piet van Oostrum |
Re: [xsl] xsl: variable comparision, Brandon Ibach | Date | Re: [xsl] Selecting the node which , Piet van Oostrum |
Month |