[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Move elements to preceding parent

Subject: Move elements to preceding parent
From: Israel Viente <israel.viente@xxxxxxxxx>
Date: Sun, 14 Jun 2009 17:53:33 +0300
 Move elements to preceding parent
Hi,
I don't have so much experience in xsl and have a task I found hard to
tackle.
I am working with Saxon-B9.1 on the command line (XSLT 1.0 or 2.0 are OK).

My input is something like the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
   <p dir="rtl">
      <span class="chapter">line1</span>
   </p>
   <p dir="rtl">&nbsp;&nbsp;<br />
   <span class="regular">line3.</span>
   <span class="italic">line4</span>
   <span class="regular">line5."</span>
   </p>
   <p dir="rtl">&nbsp;&nbsp;<br />
   <span class="regular">line6.</span>
   <br />
   <span class="regular">line7</span>
 </p>
 <p dir="rtl">&nbsp;&nbsp;<br />
   <span class="regular">line8.</span>
   <span class="regular">line9.</span>
 </p>
</body>
</html>


The reault output should be:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
   <p dir="rtl">
      <span class="chapter">line1</span>
   </p>
   <p dir="rtl">&nbsp;&nbsp;<br />
	  <span class="regular">line3.</span>
	  <span class="italic">line4</span>
	  <span class="regular">line5."</span>
   </p>
   <p dir="rtl">&nbsp;&nbsp;<br />
	  <span class="regular">line6.</span>
	  <br />
	  <span class="regular">line7</span>
	  <span class="regular">line8.</span>
	  <span class="regular">line9.</span>
   </p>
</body>
</html>

For every span element that the class<>'chapter' verify that in every
p the last span element text ends with one character of .?"!
(paragraph ending char).
If it does, copy as is to the output.
Otherwise: Move the span elements from the next p to the current one
and remove the next p completely.

I tried doing it with following-sibling & for-each , but I'm not sure
it is the right approach.

Any help will be appreciated,
Thanks, Viente

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.