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

Re: [xsl] Duplicate output for nested list Help


Subject: Re: [xsl] Duplicate output for nested list Help
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 15 Jul 2013 10:10:31 -0400

I have a few comments to make regarding style, in addition to what I think is the answer to your question.

At 2013-07-15 16:06 +1000, Edwardson Larry wrote:
This is the XML:
...

        <li><strong>Duty of Care:</strong> The [Tenancy Lookup] has the
responsibility for a duty of care, for the land. This duty of care
includes taking al reasonable steps to do the following in relation to
the land:-

<ol style=3D"list-style-type: lower-alpha">

I note in your data that <strong> and <ol> are siblings.


So in your XSLT when you test that you have an <ol> child, you process *all* children of <li> which reprocesses your <strong> a second time:

                            <xsl:if test=3D"ol">
                                <xsl:message>
                                Nested OL
                                </xsl:message>
                                <xsl:apply-templates>

You probably only want <xsl:apply-templates select="ol"> in order not to process other siblings.


But I suspect the structure of your stylesheet could be changed to do more matching so as to reduce the amount of special casing that you are doing. But it is difficult to advise without seeing more of your specification.

Regarding style, this technique of checking "what am I" is particularly frowned upon in stylesheet:

                <xsl:variable name="nodeName" select="name()"/>
...
                <xsl:if test="$nodeName = 'li'">

... where you should be using test="self::li" ... which, actually, you are using elsewhere in your stylesheet:


<xsl:apply-templates select="@* | node()[not(self::ol)]">

And your depth counting may be able to be addressed with counting nodes in the source node tree declaratively rather than imperatively maintaining depth counters in raw stylesheet code.


I hope this is helpful.

. . . . . . . . . Ken

--
Public XSLT, XSL-FO, and UBL classes in the Netherlands     Oct 2013 |
Public XSLT, XSL-FO, UBL and code list classes in Australia Oct 2013 |
Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/ |
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx |
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |


Current Thread
Keywords