xsl-list
[Top] [All Lists]

Template quitting too early?

2003-11-21 18:31:36
I have things mostly working, but I feel like I have a workaround here.
Using xsltproc... the file looks somewhat like this:

<section>
        <label>Top level</label>
        <section>
                <label>Second level</label>
                <p>Syntax: foo bar baz</p>
                <p>The actual file nests up to three deep in places.</p>
        </section>
</section>

And the relevant part of the XSLT:

<xsl:template match="section">
        <section>
                <xsl:apply-templates select="label" />
                <xsl:if test="count(p) &gt; 0">
<xsl:variable name="str"><xsl:value-of select="p[1]" /></xsl:variable>
                        <xsl:choose>
<xsl:when test='starts-with($str, "Syntax:")'> <xsl:apply-templates select="p[1]" mode="passthru" /> <xsl:apply-templates select="p[2]" mode="firstsentence" />
                                </xsl:when>
                                <xsl:otherwise>
<xsl:apply-templates select="p[1]" mode="firstsentence" />
                                </xsl:otherwise>
                        </xsl:choose>
                </xsl:if>
                <xsl:apply-templates select="section" />
        </section>
</xsl:template>

This does what I want, but I'm not sure why I need the xsl:if -- without it, it
simply stops processing any sections that have no leading paragraphs
after the label. Is that expected behavior, or is there a boogly in xsltproc?
--
Larry Kollar    k  o  l  l  a  r  @  a  l  l  t  e  l  .  n  e  t
"The hardest part of all this is the part that requires thinking."
-- Paul Tyson, on xml-doc

XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>
  • Template quitting too early?, Larry Kollar <=