Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] For-each-group problem

From: hajduk@--------
To:
Date: 10/2/2006 9:43:00 PM
(using Saxon 8 and XSLT 2)

Sorry about the earlier xml sample I wasn't paying attention and it doesn't do
justice to the content I'm working with.

Thanks for the insights Andrew and Mukul

Please take a second look at the content as you'll notice I need to grab all the
following elements before the next instance of <li> and the same for
<anotherhead>. I guess this is why I want to use for-each-group as it seems to
be a good solution.

So any ideas on how to best do this or a good sample of for-each-group would be
greatly appreciated.


Input

<root>
  <body>
    <heading>content</heading>
    <p>content</p>
    <p>content</p>

    <li>content</li>
    <div>
      <p>content</p>
      <p>content</p>
    </div>
    <p>content</p>

    <li>content</li>
    <div>
      <p>content</p>
      <p>content</p>
      <p>content</p>
      <p>content</p>
    </div>

    <li>content</li>
    <div>
      <p>content</p>
    </div>

    <anotherhead>content</anotherhead>
    <div>
      <p>content</p>
      <p>content</p>
      <p>content</p>
      <p>content</p>
    </div>

    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>    

    <anotherhead>content</anotherhead>
    <another>
      <p>content</p>
      <li>content<li>
      <div>
        <p>content</p>
        <p>content</p>
        <p>content</p>
        <p>content</p>
      </div>
    </another>

    <p>content</p>
    <footer>content</footer>
  </body>
</root>

---------------------
Output

<root>
  <body>
    <heading>content</heading>
    <p>content</p>
    <p>content</p>

    <ul>
      <li>
        <p>content</p>
        <div>
          <p>content</p>
          <p>content</p>
        </div>
        <p>content</p>
      </li>

      <li>
        <p>content</p>
        <div>
          <p>content</p>
          <p>content</p>
          <p>content</p>
        </div>
      </li>

      <li>
        <p>content</p>
        <div>
          <p>content</p>
        </div>
      </li>
    </ul>

    <div>
      <anotherhead>content</anotherhead>
      <another>
        <p>content</p>
        <p>content</p>
        <p>content</p>
        <p>content</p>
      </another>
      <p>content</p>
      <p>content</p>
      <p>content</p>
      <p>content</p>
    </div>

    <div>
      <anotherhead>content</anotherhead>
       <another>
        <p>content</p>
        <ul>
          <li>
            <p>content</p>
            <div>
              <p>content</p>
              <p>content</p>
              <p>content</p>
              <p>content</p>
            </div>
          </li>
        </ul>
      </another>
    </div>

    <p>content</p>
    <footer>content</footer>
  </body>
</root>

Thanks

Mario


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent