RE: [xsl] Selecting everything "before" and "after" a specific node

Subject: RE: [xsl] Selecting everything "before" and "after" a specific node
From: Emmanuel Bégué <eb@xxxxxxxxxx>
Date: Thu, 2 Apr 2009 13:27:09 +0200
Hello,

I did see your message on the xep mailing list and the
answer by G. Ken Holman, and I offered to send the
stylesheet I had made that does just that (currently
based on an element name for the break, not an
attribute value).

I find it's a complicated problem that I don't think
can be explained easily (not by me anyway ;-)

I'm sending the stylesheet to you in a separate
message.

If you run the stylesheet on a slightly modified version
of your source (Z instead of E when i=9):

<A i="1">
	<B i="2">
		<C i="3"/>
		</B>
	<B i="4">
		<C i="5">
			<D i="6"/>
			<D i="7">
				<E i="8"/>
				<Z i="9" msg="get me out of here!"/>
				<E i="10"/>
				</D>
			<D i="11"/>
			</C>
		<C i="12"/>
		</B>
	</A>


you get the following result:

<root>
   <A i="1">
      <B i="2">
         <C i="3"/>
      </B>
      <B i="4">
         <C i="5">
            <D i="6"/>
            <D i="7">
               <E i="8"/>
            </D>
         </C>
      </B>
   </A>
   <Z i="9" msg="get me out of here!"/>
   <A i="1">
      <B i="4">
         <C i="5">
            <D i="7">
               <E i="10"/>
            </D>
            <D i="11"/>
         </C>
         <C i="12"/>
      </B>
   </A>
</root>

Regards,
EB

> -----Original Message-----
> From: Paul Harvey [mailto:paul_harv_2@xxxxxxxxx]
> Sent: Thursday, April 02, 2009 1:07 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Selecting everything "before" and "after" a specific node
>
>
>
> Hi,
> Ibve searched and posted on another list, but have not found an
> answer to this problemb&
> I have XML like this...
>
> <A i=b1b>
>       <B i=b2b>
>             <C i=b3b/>
>       </B>
>       <B i=b4b>
>             <C i=b5b>
>                   <D i=b6b/>
>                   <D i=b7b>
>                         <E i=b8b/>
>                         <E i=b9b msg="get me out of here!"/>
>                         <E i=b10b/>
>                   </D>
>                   <D i=b11b/>
>             </C>
>             <C i=b12b/>
>       </B>
> </A>
> And I need to break it out into 3 nodesets, delimited by the <E
> i=b9b msg="get me out of here!"/> such that Ibd end up with...
> <ROOT>
>        <BEFORE>
>         <A i=b1b>
>                   <B i=b2b>
>                         <C i=b3b/>
>                   </B>
>                   <B i=b4b>
>                         <C i=b5b>
>                               <D i=b6b/>
>                               <D i=b7b>
>                                     <E i=b8b/>
>                               </D>
>                         </C>>
>                   </B>
>         </A>
>        </BEFORE>
>        <PULLED_OUT>
>             <E id=b9b msg="get me out of here!"/>
>        </PULLED_OUT>
>        <AFTER>
>         <A i=b1b>
>                   <B i=b4b>
>                         <C i=b5b>
>                               <D i=b7b>
>                                     <E i=b10b/>
>                               </D>
>                               <D i=b11b/>
>                         </C>
>                         <C i=b12b/>
>                   </B>
>         </A>
>        </AFTER>
> </ROOT>
>
> Any suggestions as to how Ibd go about that?
> I've spent some time with preceding and following axis, and some
> other conditions, but this has not got me where I need to get as yet.
>
> Thanks so much,
>
> Paul

Current Thread