xsl-list
[Top] [All Lists]

Re: [xsl] Selecting the node which have child without repition

2010-11-18 22:00:07
The following XPath expression seem to work:

//b[c][not(@name = following::b[c]/@name)]

On Thu, Nov 18, 2010 at 11:05 PM, Rashi Bhardwaj
<rashi(_dot_)bhardwaj(_at_)gmail(_dot_)com> 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




-- 
Regards,
Mukul Gandhi

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>