[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Move elements to preceding parent


Subject: Re: [xsl] Move elements to preceding parent
From: Israel Viente <israel.viente@xxxxxxxxx>
Date: Wed, 17 Jun 2009 15:26:13 +0300

Input:
<?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"><span class="regular">line10</span>
 <span class="regular">line11</span>
 </p>
 <p dir="rtl"><span class="regular">line12</span>
 </p>
<p dir="rtl"><span class="regular">line13.</span>
</p>
<p dir="rtl"><span class="regular">line14</span>
</p>
<p dir="rtl"><span class="regular">line15</span>
</p>
<p dir="rtl"><span class="regular">line16.</span>
</p>
<p dir="rtl"><span class="regular">line17"</span>
</p>

</body>
</html>

Required output:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
   <body>

      <p dir="rtl">
         <span class="chapter">line1</span>
       </p>

      <p dir="rtl">
         <span class="regular">line10</span>
         <span class="regular">line11</span>
         <span class="regular">line12</span>
         <span class="regular">line13.</span>
      </p>

      <p dir="rtl">
          <span class="regular">line14</span>
         <span class="regular">line15</span>
         <span class="regular">line16.</span>
      </p>

      <p dir="rtl">
         <span class="regular">line17"</span>
      </p>

   </body>
</html>

Thanks.

On Wed, Jun 17, 2009 at 3:03 PM, Martin Honnen<Martin.Honnen@xxxxxx> wrote:
> Israel Viente wrote:
>
>> Meanwhile I found that I have input cases where the 2 rules are ambiguous.
>>
>> For example if the input is as follows:
>>
>> <?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"><span class="regular">line10</span>
>>  <span class="regular">line11</span>
>>  </p>
>>  <p dir="rtl"><span class="regular">line12</span>
>>  </p>
>> <p dir="rtl"><span class="regular">line13.</span>
>> </p>
>>
>> </body>
>> </html>
>>
>> the error I get is:
>> Recoverable error
>>  XTRE0540: Ambiguous rule match for /html/body[1]/p[3]
>
>
>> How can I make a rule that will take all the following-sibling p's
>> internal nodes until it finds one that it's last span ends with
>> paragraph terminator? And of course change the 2nd rule accordingly to
>> remove those merged to the upper sibling.
>
> How do you want to transform that sample you posted? Can you show us how
the
> transformation result should look?
>
> --
>
>        Martin Honnen
>        http://msmvps.com/blogs/martin_honnen/


Current Thread
Keywords