This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: DocBook XML / XSL Problems (attribute tests seemalways true)
- From: Bob Stayton <bobs at caldera dot com>
- To: benjamin at tolkbib dot de, docbook-apps at lists dot oasis-open dot org
- Date: Sun, 25 Nov 2001 20:27:22 -0800 (PST)
- Subject: Re: DOCBOOK-APPS: DocBook XML / XSL Problems (attribute tests seemalways true)
- List-id: <docbook-apps.lists.oasis-open.org>
> From: Benjamin Peter <benjamin@tolkbib.de>
>
> Hello,
>
> I have spent several hourse on the problem I posted before and have
> found out that:
>
> I am not getting chapter, section, figure numbers because the test
> for @label will be true even if I have no label attribute in the tag.
>
> Example:
>
> a) the xml fragment:
> <figure><title>My Sample Figure</title>
> <graphic fileref="sample.jpg"/>
> </figure>
>
> b) the matching template that will generate the label (fragment)
>
> I have modified this to tell me whether a @label was found which
> will override the automatically generated id.
>
> Running it against above xml file (saxon 6.4.2, docbook xml 4.1.2)
> will output 'Label found:'
>
> <xsl:choose>
> <xsl:when test="@label">
> <xsl:message>
> Label found:
> <xsl:value-of select="@label"/></xsl:message>
> <xsl:value-of select="@label"/>
> </xsl:when>
> <xsl:otherwise>
> <!-- Generate the label automatically -->
> </xsl:otherwise>
> </xsl:choose>
>
> c) working template:
>
> When I modify the line that tests for @label to read
>
> <xsl:when test="@label and not(string-length(@label)=0)">
>
> everything works fine.
>
>
> The same problem occurs in several other cases (e.g. an existing but
> empty @scale in graphic will render as an image with a width of "%" in
> HTML :-(
>
> I understand that the modification of the templates is merely a way to
> pinpoint my problem, not the solution. I have however no idea what the
> solution might look like.
>
> If anyone else has this problem and a solution along with it, please
> drop me a line.
Perhaps upgrade to Saxon 6.4.4. I just tried it and I get
figure numbers ok. If a missing 'label' attribute
generates a true value for test="@label" as your test
demonstrates, then that has to be a bug in the XSL
processor. An empty node or empty string is false (quoting
Michael Kay's XSLT Programmer's Reference 2nd ed. page
453).
bobs
Bob Stayton 400 Encinal Street
Publications Architect Santa Cruz, CA 95060
Technical Publications voice: (831) 427-7796
Caldera International, Inc. fax: (831) 429-1887
email: bobs@caldera.com