Variable Length Ordered Lists Using XSL


I’m attempting to create an ordered list every time the Sequence attribute of a Para element has been set to ‘Begin’. The list should continue until it reaches a paragraph with the Sequence attribute set to ‘End’. The problem arises because the

are not being properly matched within the XSL document. I have tried various combinations of
    , CData, and CDATA sections.

  1. Answer:

    This can be a real pain?I’ve run into similar situations, where you need to be able to wrap a tag around an expression but the tag start and tag end are generated programmatically (and hence appear “unbalanced” to the XSL document). The simplest solution (and it isn’t terribly simple), is to recognize that you need to abstract your structure out one level. What you have is this:

    First ParagraphSecond ParagraphThird ParagraphFourth ParagraphFifth ParagraphSixth Paragraph

    The problem with this code is that you’re actually subverting the intrinsic structure of the code, flattening the hierarchy too much. There is no clean way to write an XPath query that will satisfy this.However, if you recognized that each of these items exist in groups, then you could revamp your structure a bit:

       First Paragraph   Second Paragraph   Third Paragraph   Fourth Paragraph   Fifth Paragraph   Sixth Paragraph

    Then the XSL transform becomes much simpler:

  2. This actually brings up a good point to remember about XSL?in general, whenever you have an order issue involved (or, as in this example, you seem to have unbalanced elements), this is typically an indication that your hierarchy is too flat. By deepening the hierarchy, encapsulating it if you will, you can usually solve such problems.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS