You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Edward Dowgiallo <ed...@ptdprolog.net> on 2001/12/07 23:20:23 UTC
xsl:choice
I seem to be not getting the intended use of xsl:choice.
The following stylesheet segment causes fop to terminate with the message: ...; Line 78 Column 25; [ERROR]: null
<fo:block font-family="Helvetica" font-size="18pt" text-align="end">
<xsl:choice>
<xsl:when test="//eraname">
<xsl:value-of select="//eraname"/>
</xsl:when>
<xsl:when test="//conflictname">
<xsl:value-of select="//conflictname"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>History of the World</xsl:text>
</xsl:otherwise>
<xsl:choice>
</fo:block>
1st, a more verbose error message would be useful.
2nd, What I am trying to do is find out if the current element contains an element named "eraname", if it does I want to use the value of the element "eraname"
If it doesn't I want to check if the current element contains a child element named "conflictname", if it does I want to use the value of the element "conflictname".
If it doesn't I want to slap in some boiler plate text.
The xml file being processed when this fails does contain the child element "eraname".
I'd be more than happy to use a workaround here.
Thank you,
Ed
Re: xsl:choice
Posted by ronald heller <ro...@salience.nl>.
xsl:choice is not a xsl element, you probably mean xsl:choose
RH
At 02:38 PM 12/7/01 -0800, you wrote:
>Edward
>
>#1 You should be sending these questions to the XSL list
>#2 You need to use a dot at the front of your query so that the current
>context is set (.//eraname)
>
>Chuck
>
>Edward Dowgiallo wrote:
>
>>I seem to be not getting the intended use of xsl:choice.
>>
>>
>>
>>The following stylesheet segment causes fop to terminate with the
>>message: ...; Line 78 Column 25; [ERROR]: null
>>
>>
>>
>> <fo:block font-family="Helvetica" font-size="18pt"
>> text-align="end">
>> <xsl:choice>
>> <xsl:when test="//eraname">
>> <xsl:value-of select="//eraname"/>
>> </xsl:when>
>> <xsl:when test="//conflictname">
>> <xsl:value-of select="//conflictname"/>
>> </xsl:when>
>> <xsl:otherwise>
>> <xsl:text>History of the World</xsl:text>
>> </xsl:otherwise>
>> <xsl:choice>
>> </fo:block>
>>
>>1st, a more verbose error message would be useful.
>>
>>
>>
>>2nd, What I am trying to do is find out if the current element contains
>>an element named "eraname", if it does I want to use the value of the
>>element "eraname"
>>
>>If it doesn't I want to check if the current element contains a child
>>element named "conflictname", if it does I want to use the value of the
>>element "conflictname".
>>
>>If it doesn't I want to slap in some boiler plate text.
>>
>>
>>
>>The xml file being processed when this fails does contain the child
>>element "eraname".
>>
>>
>>
>>I'd be more than happy to use a workaround here.
>>
>>
>>
>>Thank you,
>>
>>Ed
>
>
Salience B.V.
Ronald Heller
Technisch Consultant
Coltbaan 27b
3439 NG Nieuwegein
Telefoon 030 60 56 675
Telefax 030 60 56 324
Website www.salience.nl
ronald@salience.nl
Mobiel 06 20 41 25 77
ICQ 135511393
Re: xsl:choice
Posted by Chuck Paussa <Ch...@systems.dhl.com>.
Edward
#1 You should be sending these questions to the XSL list
#2 You need to use a dot at the front of your query so that the current
context is set (.//eraname)
Chuck
Edward Dowgiallo wrote:
> I seem to be not getting the intended use of xsl:choice.
>
>
>
> The following stylesheet segment causes fop to terminate with the
> message: ...; Line 78 Column 25; [ERROR]: null
>
>
>
> <fo:block font-family="Helvetica" font-size="18pt"
> text-align="end">
> <xsl:choice>
> <xsl:when test="//eraname">
> <xsl:value-of select="//eraname"/>
> </xsl:when>
> <xsl:when test="//conflictname">
> <xsl:value-of select="//conflictname"/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:text>History of the World</xsl:text>
> </xsl:otherwise>
> <xsl:choice>
> </fo:block>
>
> 1st, a more verbose error message would be useful.
>
>
>
> 2nd, What I am trying to do is find out if the current element
> contains an element named "eraname", if it does I want to use the
> value of the element "eraname"
>
> If it doesn't I want to check if the current element contains a child
> element named "conflictname", if it does I want to use the value of
> the element "conflictname".
>
> If it doesn't I want to slap in some boiler plate text.
>
>
>
> The xml file being processed when this fails does contain the child
> element "eraname".
>
>
>
> I'd be more than happy to use a workaround here.
>
>
>
> Thank you,
>
> Ed
>
Re: xsl:choice
Posted by Matt Savino <ma...@synergizethis.com>.
Try xsl:choose.
I'm available for consulting.
> Edward Dowgiallo wrote:
>
> I seem to be not getting the intended use of xsl:choice.
>
> The following stylesheet segment causes fop to terminate with the
> message: ...; Line 78 Column 25; [ERROR]: null
>
> <fo:block font-family="Helvetica" font-size="18pt"
> text-align="end">
> <xsl:choice>
> <xsl:when test="//eraname">
> <xsl:value-of select="//eraname"/>
> </xsl:when>
> <xsl:when test="//conflictname">
> <xsl:value-of select="//conflictname"/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:text>History of the World</xsl:text>
> </xsl:otherwise>
> <xsl:choice>
> </fo:block>
> 1st, a more verbose error message would be useful.
>
> 2nd, What I am trying to do is find out if the current element
> contains an element named "eraname", if it does I want to use the
> value of the element "eraname"
> If it doesn't I want to check if the current element contains a child
> element named "conflictname", if it does I want to use the value of
> the element "conflictname".
> If it doesn't I want to slap in some boiler plate text.
>
> The xml file being processed when this fails does contain the child
> element "eraname".
>
> I'd be more than happy to use a workaround here.
>
> Thank you,
> Ed
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org
Re: xsl:choice
Posted by Matt Savino <ma...@synergizethis.com>.
Yeah, it just gets a little cumbersome if you have, say, five cases.
Scott Moore wrote:
>
> The <xsl:choose> statement is exactly like a switch or case statement. You
> CAN have one or more <xsl:when> statements underneath the same <xsl:choose>
> parent followed by one <xsl:otherwise>, which is equivalent to "default:" in
> Java or C++.
>
> I use this construct all the time, especially when I need something similiar
> to "if then else" or a switch statement.
>
> Scott
>
> ----- Original Message -----
> From: "Matt Savino" <ma...@synergizethis.com>
> To: <fo...@xml.apache.org>
> Sent: Friday, December 07, 2001 10:46 PM
> Subject: Re: xsl:choice
>
> > Sorry, I didn't read the bottom.
> >
> > You can only include one <xsl:when> as a child of <xsl:choose>. (There
> > is no concept of a case switch or elsif in XSLT.)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> For additional commands, email: fop-dev-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org
Re: xsl:choice
Posted by Scott Moore <sc...@netdecide.com>.
The <xsl:choose> statement is exactly like a switch or case statement. You
CAN have one or more <xsl:when> statements underneath the same <xsl:choose>
parent followed by one <xsl:otherwise>, which is equivalent to "default:" in
Java or C++.
I use this construct all the time, especially when I need something similiar
to "if then else" or a switch statement.
Scott
----- Original Message -----
From: "Matt Savino" <ma...@synergizethis.com>
To: <fo...@xml.apache.org>
Sent: Friday, December 07, 2001 10:46 PM
Subject: Re: xsl:choice
> Sorry, I didn't read the bottom.
>
> You can only include one <xsl:when> as a child of <xsl:choose>. (There
> is no concept of a case switch or elsif in XSLT.)
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org
Re: xsl:choice
Posted by Matt Savino <ma...@synergizethis.com>.
Sorry, I didn't read the bottom.
You can only include one <xsl:when> as a child of <xsl:choose>. (There
is no concept of a case switch or elsif in XSLT.)
test="//eraname" returns true if there is an element <eraname> anywhere
in the document. To search only the children of the current node, take
out the '//' part.
To do what you want try this (anyone knows of a more elegant method,
please chime in):
<fo:block font-family="Helvetica" font-size="18pt"
text-align="end">
<xsl:choose>
<xsl:when test="eraname or conflictname">
<xsl:choose>
<xsl:when test="eraname">
<xsl:value-of select="eraname"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="conflictname"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:text>History of the World</xsl:text>
</xsl:otherwise>
</xsl:choose>
</fo:block>
> Edward Dowgiallo wrote:
>
> I seem to be not getting the intended use of xsl:choice.
>
> The following stylesheet segment causes fop to terminate with the
> message: ...; Line 78 Column 25; [ERROR]: null
>
> <fo:block font-family="Helvetica" font-size="18pt"
> text-align="end">
> <xsl:choice>
> <xsl:when test="//eraname">
> <xsl:value-of select="//eraname"/>
> </xsl:when>
> <xsl:when test="//conflictname">
> <xsl:value-of select="//conflictname"/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:text>History of the World</xsl:text>
> </xsl:otherwise>
> <xsl:choice>
> </fo:block>
> 1st, a more verbose error message would be useful.
>
> 2nd, What I am trying to do is find out if the current element
> contains an element named "eraname", if it does I want to use the
> value of the element "eraname"
> If it doesn't I want to check if the current element contains a child
> element named "conflictname", if it does I want to use the value of
> the element "conflictname".
> If it doesn't I want to slap in some boiler plate text.
>
> The xml file being processed when this fails does contain the child
> element "eraname".
>
> I'd be more than happy to use a workaround here.
>
> Thank you,
> Ed
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org