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

List type, probably a sequence problem (XSL 2)

Subject: List type, probably a sequence problem (XSL 2)
From: "Trevor Nicholls trevor@xxxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 8 Jun 2023 18:40:48 -0000
 List type
Hi

 

I think this problem should be really simple but whatever I try rapidly gets
inordinately complicated.

 

I'm processing documents which contain, among many other things, "list"
elements and "steps" elements. Steps really are a special class of list but
they are represented by a different element in the schema, for reasons.

My stylesheet outputs html, and both lists and steps produce <ol> elements
with different attributes.

When I meet a list element, I need to decide whether this list should be
presented with numbered elements, or lettered elements.

 

The rules are that steps should always be numbered. Lists should always use
the alternate scheme to their nearest ancestor, and a list with no ancestor
list or step should be numeric.

 

e.g.

 

<document>

  <list>

    <li>This list will produce an ol class="decimal"</li>

    <li/>

    <li>

      <list>

        <li>This list will produce an ol class="alpha"</li>

        <li>

          <list>

            <li>This list will produce an ol class="decimal"</li>

            <li>

              <steps>

                <step>These steps will produce an ol class="decimal"</step>

                <step>

                  <list>

                    <li>This list will produce an ol class="alpha"</li>

                    <li/>

                  </list>

                </step>

              </steps>

            </li>

          </list>

        </li>

      </list>

    </li>

  </list>

</document>

 

 

If steps followed the same rules as lists it would be easy, just construct a
sequence of list or steps ancestors:

 

  <xsl:variable name="ancestral_lists" as="node*" select="ancestor::list |
ancestor::steps" />

 

and choose class="decimal" if count($ancestral_lists) is even, class="alpha"
if odd.

 

But steps are always numbered, so I actually need to count the number of
lists after the final step (if any), and invert the numbering/lettering
scheme if the sequence included any steps.

 

I thought I could do this with index-of() but unless I'm mistaken that tests
the values of the sequence members not their element names.

At this point I decided I'm probably on the wrong track and thought I'd ask
for help.

 

Is there a nice way to implement this?

 

cheers

T

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-2013 All Rights Reserved.