This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: XSLT 'or' statement (Was Re: How can I getstylesheet to bold?)
- To: Dan York <dyork at e-smith dot com>
- Subject: Re: XSLT 'or' statement (Was Re: DOCBOOK-APPS: How can I getstylesheet to bold?)
- From: Adam Turoff <ziggy at panix dot com>
- Date: Tue, 31 Jul 2001 15:19:17 -0400
- Cc: docbook-apps at lists dot oasis-open dot org
- References: <20010731133931.B3090@e-smith.com>
On Tue, Jul 31, 2001 at 01:39:38PM -0400, Dan York wrote:
> > <xsl:template match="emphasis">
> > <xsl:choose>
> > <xsl:when test="@role='bold'|@role='strong'"> <!-- changed line -->
> > <xsl:call-template name="inline.boldseq"/>
> > </xsl:when>
> > <xsl:otherwise>
> > <xsl:call-template name="inline.italicseq"/>
> > </xsl:otherwise>
> > </xsl:choose>
> > </xsl:template>
>
> However, in running it through 'xsltproc' I found that I was getting
> an error generated. It actually seemed to work correctly, but gave me
> error messages. I did some research and found that the 'or' functionality
> of XSLT actually uses the word "or". So the test needs to be:
>
> <xsl:when test="(@role='strong') or (@role='bold')">
>
> Once I changed that, everything worked fine and no errors were
> produced. One source for this is on the XPath page at:
>
> http://www.w3.org/TR/xpath#booleans
>
> I was a bit surprised as I expected the "|" symbol to work, but it
> appears that it is at least not "proper" XSLT. (At least that is
> what I could see in the docs.)
Dan,
The '|' operator creates the union of 2 XPath location paths. The 'or'
operator evaluates the boolean or of two XPath predicates. Both
predicates and location paths are valid XPath expressions, but they
can be used in completely different contexts:
Location paths:
section | sect1 | sect2 | sect3 | sect4 | sect5
/book/title | /article/title
Predicates (and similar expressions):
@role='bold' or @role='strong'
count(ancestor::section) = 0 or @id='1'
The easiest thing to do is to know when you're dealing with a location
path, and know when you're dealing with a predicate or other such expression.
Hope this helps,
Z.
------------------------------------------------------------------
To unsubscribe from this elist send a message with the single word
"unsubscribe" in the body to: docbook-apps-request@lists.oasis-open.org