-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: LovedJohnySmith
Message 2 in Discussion

Dharshan:                 I can understand your problem, let me go through your 
problem here... You have as input, the following XML snippet:  
<A>foo</A> 
<B>bar</B> 
<A>fubar</A> 
<B>foobar</B> 
<B>foofoobar</B>   this should be following format right? 
The structure is that after each A element, there are one or more B 
elements.  (B should have been a child of A, but unfortunately is a 
sibling).  In that case the output should look like this.  
<A>foo 
  <B>bar</B> 
</A> 
<A>fubar 
  <B>foobar</B> 
  <B>foofoobar</B> 
</A>    But, what you want is taking every B element following-sibling an A 
element, but 
before any other following-sibling A element, and make it a child of the 
reference A element. 
 
In other term, for-each A element, take 
following-sibling::B[generate-id(preceding-sibling::A[1]) = 
generate-id(current())] and make it a child of A. 
 
I let you translate this into XSLT, you have the XPath part and the algorithm. 
Please note that the second tree structure isn't really a "good" structure, 
in that it uses "mixed content" model for data that doesn't seem to be 
"mixed content". You should IMO put the text children of the first A nodes 
into an attribute or another child element: 
<A attr="foo"> 
  <B>bar</B> 
</A> 
<A attr="fubar"> 
  <B>foobar</B> 
  <B>foofoobar</B> 
</A> 
 
Thanx, 
Smith 
http://spaces.msn.com/members/johnysmith 
 

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to