Steffanina, Jeff | 7 Oct 20:52

Using CHOOSE to control image in region-body


FOP 0.95 / Redhat Linux / Java 1.5

When the tag "send-fax" does not exist print the lilly, when send-fax=Y, print the pebble.  I always get the Lilly.  Can you determine why?

<xsl:choose>
  <xsl:when test="./send-fax='Y'">
       <!--   region-before means region before the body(top 1/3 of folio   -->
       <fo:region-before extent="3.0in"
                    background-repeat="no-repeat"
                    margin-top=".5in"
                    background-image="url('java/images/Pebble.jpg')"
                    background-position-vertical="bottom"
                    display-align="after" />
  </xsl:when>
  <xsl:otherwise>
      <fo:region-before extent="3.0in"
                    background-repeat="no-repeat"
                    margin-top=".5in"
                    background-image="url('java/images/Lilly.jpg')"
                    background-position-vertical="bottom"
                    display-align="after" />
  </xsl:otherwise>
</xsl:choose>



Jeff

Amick, Eric | 7 Oct 21:11
Picon

RE: Using CHOOSE to control image in region-body

I can think of two possibilities off the top of my head: The value is a lowercase Y, or there is whitespace present. Try normalize-space(send-fax)='Y' instead.
 
Eric Amick
Legislative Computer Systems
Office of the Clerk
 

From: Steffanina, Jeff [mailto:Jeff.Steffanina <at> marriott.com]
Sent: Tuesday, October 7, 2008 14:54
To: fop-users <at> xmlgraphics.apache.org
Subject: Using CHOOSE to control image in region-body


FOP 0.95 / Redhat Linux / Java 1.5

When the tag "send-fax" does not exist print the lilly, when send-fax=Y, print the pebble.  I always get the Lilly.  Can you determine why?

<xsl:choose>
  <xsl:when test="./send-fax='Y'">
       <!--   region-before means region before the body(top 1/3 of folio   -->
       <fo:region-before extent="3.0in"
                    background-repeat="no-repeat"
                    margin-top=".5in"
                    background-image="url('java/images/Pebble.jpg')"
                    background-position-vertical="bottom"
                    display-align="after" />
  </xsl:when>
  <xsl:otherwise>
      <fo:region-before extent="3.0in"
                    background-repeat="no-repeat"
                    margin-top=".5in"
                    background-image="url('java/images/Lilly.jpg')"
                    background-position-vertical="bottom"
                    display-align="after" />
  </xsl:otherwise>
</xsl:choose>



Jeff

Steffanina, Jeff | 7 Oct 21:37

RE: Using CHOOSE to control image in region-body

Eric,
I made the suggested change and checked the case.   No difference in the output.
 
Any other thoughts?

Jeff

From: Amick, Eric [mailto:Eric.Amick <at> mail.house.gov]
Sent: Tuesday, October 07, 2008 3:11 PM
To: fop-users <at> xmlgraphics.apache.org
Subject: RE: Using CHOOSE to control image in region-body

I can think of two possibilities off the top of my head: The value is a lowercase Y, or there is whitespace present. Try normalize-space(send-fax)='Y' instead.
 
Eric Amick
Legislative Computer Systems
Office of the Clerk
 

From: Steffanina, Jeff [mailto:Jeff.Steffanina <at> marriott.com]
Sent: Tuesday, October 7, 2008 14:54
To: fop-users <at> xmlgraphics.apache.org
Subject: Using CHOOSE to control image in region-body


FOP 0.95 / Redhat Linux / Java 1.5

When the tag "send-fax" does not exist print the lilly, when send-fax=Y, print the pebble.  I always get the Lilly.  Can you determine why?

<xsl:choose>
  <xsl:when test="./send-fax='Y'">
       <!--   region-before means region before the body(top 1/3 of folio   -->
       <fo:region-before extent="3.0in"
                    background-repeat="no-repeat"
                    margin-top=".5in"
                    background-image="url('java/images/Pebble.jpg')"
                    background-position-vertical="bottom"
                    display-align="after" />
  </xsl:when>
  <xsl:otherwise>
      <fo:region-before extent="3.0in"
                    background-repeat="no-repeat"
                    margin-top=".5in"
                    background-image="url('java/images/Lilly.jpg')"
                    background-position-vertical="bottom"
                    display-align="after" />
  </xsl:otherwise>
</xsl:choose>



Jeff

Pete Allison | 7 Oct 21:56
Picon
Favicon

RE: Using CHOOSE to control image in region-body

What is the context for "./send-fax" ?
 
 

From: Steffanina, Jeff [mailto:Jeff.Steffanina <at> marriott.com]
Sent: Tuesday, October 07, 2008 2:38 PM
To: fop-users <at> xmlgraphics.apache.org
Subject: RE: Using CHOOSE to control image in region-body

Eric,
I made the suggested change and checked the case.   No difference in the output.
 
Any other thoughts?

Jeff

From: Amick, Eric [mailto:Eric.Amick <at> mail.house.gov]
Sent: Tuesday, October 07, 2008 3:11 PM
To: fop-users <at> xmlgraphics.apache.org
Subject: RE: Using CHOOSE to control image in region-body

I can think of two possibilities off the top of my head: The value is a lowercase Y, or there is whitespace present. Try normalize-space(send-fax)='Y' instead.
 
Eric Amick
Legislative Computer Systems
Office of the Clerk
 

From: Steffanina, Jeff [mailto:Jeff.Steffanina <at> marriott.com]
Sent: Tuesday, October 7, 2008 14:54
To: fop-users <at> xmlgraphics.apache.org
Subject: Using CHOOSE to control image in region-body


FOP 0.95 / Redhat Linux / Java 1.5

When the tag "send-fax" does not exist print the lilly, when send-fax=Y, print the pebble.  I always get the Lilly.  Can you determine why?

<xsl:choose>
  <xsl:when test="./send-fax='Y'">
       <!--   region-before means region before the body(top 1/3 of folio   -->
       <fo:region-before extent="3.0in"
                    background-repeat="no-repeat"
                    margin-top=".5in"
                    background-image="url('java/images/Pebble.jpg')"
                    background-position-vertical="bottom"
                    display-align="after" />
  </xsl:when>
  <xsl:otherwise>
      <fo:region-before extent="3.0in"
                    background-repeat="no-repeat"
                    margin-top=".5in"
                    background-image="url('java/images/Lilly.jpg')"
                    background-position-vertical="bottom"
                    display-align="after" />
  </xsl:otherwise>
</xsl:choose>



Jeff

Steffanina, Jeff | 7 Oct 21:59

RE: Using CHOOSE to control image in region-body

 
Located in the XML file:
 
        <send-fax>Y</send-fax>
 
 
 

Jeff

From: Pete Allison [mailto:macsmaker <at> aol.com]
Sent: Tuesday, October 07, 2008 3:56 PM
To: fop-users <at> xmlgraphics.apache.org
Subject: RE: Using CHOOSE to control image in region-body

What is the context for "./send-fax" ?
 
 

From: Steffanina, Jeff [mailto:Jeff.Steffanina <at> marriott.com]
Sent: Tuesday, October 07, 2008 2:38 PM
To: fop-users <at> xmlgraphics.apache.org
Subject: RE: Using CHOOSE to control image in region-body

Eric,
I made the suggested change and checked the case.   No difference in the output.
 
Any other thoughts?

Jeff

From: Amick, Eric [mailto:Eric.Amick <at> mail.house.gov]
Sent: Tuesday, October 07, 2008 3:11 PM
To: fop-users <at> xmlgraphics.apache.org
Subject: RE: Using CHOOSE to control image in region-body

I can think of two possibilities off the top of my head: The value is a lowercase Y, or there is whitespace present. Try normalize-space(send-fax)='Y' instead.
 
Eric Amick
Legislative Computer Systems
Office of the Clerk
 

From: Steffanina, Jeff [mailto:Jeff.Steffanina <at> marriott.com]
Sent: Tuesday, October 7, 2008 14:54
To: fop-users <at> xmlgraphics.apache.org
Subject: Using CHOOSE to control image in region-body


FOP 0.95 / Redhat Linux / Java 1.5

When the tag "send-fax" does not exist print the lilly, when send-fax=Y, print the pebble.  I always get the Lilly.  Can you determine why?

<xsl:choose>
  <xsl:when test="./send-fax='Y'">
       <!--   region-before means region before the body(top 1/3 of folio   -->
       <fo:region-before extent="3.0in"
                    background-repeat="no-repeat"
                    margin-top=".5in"
                    background-image="url('java/images/Pebble.jpg')"
                    background-position-vertical="bottom"
                    display-align="after" />
  </xsl:when>
  <xsl:otherwise>
      <fo:region-before extent="3.0in"
                    background-repeat="no-repeat"
                    margin-top=".5in"
                    background-image="url('java/images/Lilly.jpg')"
                    background-position-vertical="bottom"
                    display-align="after" />
  </xsl:otherwise>
</xsl:choose>



Jeff

Picon

Re: Using CHOOSE to control image in region-body

Steffanina, Jeff a écrit :
>  
> Located in the XML file:
>  
>         <send-fax>Y</send-fax>
>  
>  
Recently, in a reasonably similar problem (though a bit more 
complicated) I used
<xsl:if test="count(send-fax) = 0">

Not very elegant but it did the trick for me, and it might do for you if 
the only thing you need is test the existence of send-fax.
Picon

Re: Using CHOOSE to control image in region-body

Jean-François El Fouly a écrit :
> Steffanina, Jeff a écrit :
>>  
>> Located in the XML file:
>>  
>>         <send-fax>Y</send-fax>
>>  
>>  
> Recently, in a reasonably similar problem (though a bit more 
> complicated) I used
> <xsl:if test="count(send-fax) = 0">
>
> Not very elegant but it did the trick for me, and it might do for you 
> if the only thing you need is test the existence of send-fax.
>
And BTW if send-fax is not a direct child of the node you're processing 
but a remote descendant, you should write my condition with an axe:
<xsl:if test="count(//send-fax) = 0">
Jay Bryant | 7 Oct 23:47

Re: Using CHOOSE to control image in region-body

> And BTW if send-fax is not a direct child of the node you're processing 
> but a remote descendant, you should write my condition with an axe:
> <xsl:if test="count(//send-fax) = 0">

That will count every instance of send-fax in the whole document.

To count descendants of the current node named send-fax to any depth, use 
count(.//send-fax).

./send-fax is the same as just send-fax because the child axis (represented 
by .) is the default axis. However, // starts at the document root unless 
it's preceded by an axis specifier. Conseqently, you don't need the . (or 
the /) in ./send-fax, but you do need it in .//send-fax.

Jay Bryant 
Kendall Shaw | 7 Oct 23:00

Re: Using CHOOSE to control image in region-body

Steffanina, Jeff wrote:
>  
> Located in the XML file:
>  
>         <send-fax>Y</send-fax>
>

Located where? Probably there is no send-fax element with the text 
content 'Y' that is a child of the context node. I suspect that the 
context node is something other than what you expect in the place where 
that choose instruction is. For example, if the choose is inside a 
for-each the context node is probably not what it was when the template 
matched.

Incidentally, "./send-fax='Y'" is the same as "send-fax='Y'".

Kendall

>  
>  
>
> */Jeff /*
>
> ------------------------------------------------------------------------
> *From:* Pete Allison [mailto:macsmaker <at> aol.com]
> *Sent:* Tuesday, October 07, 2008 3:56 PM
> *To:* fop-users <at> xmlgraphics.apache.org
> *Subject:* RE: Using CHOOSE to control image in region-body
>
>     What is the context for "./send-fax" ?
>      
>      
>
>     ------------------------------------------------------------------------
>     *From:* Steffanina, Jeff [mailto:Jeff.Steffanina <at> marriott.com]
>     *Sent:* Tuesday, October 07, 2008 2:38 PM
>     *To:* fop-users <at> xmlgraphics.apache.org
>     *Subject:* RE: Using CHOOSE to control image in region-body
>
>     Eric,
>     I made the suggested change and checked the case.   No difference
>     in the output.
>      
>     Any other thoughts?
>
>     */Jeff /*
>
>         ------------------------------------------------------------------------
>         *From:* Amick, Eric [mailto:Eric.Amick <at> mail.house.gov]
>         *Sent:* Tuesday, October 07, 2008 3:11 PM
>         *To:* fop-users <at> xmlgraphics.apache.org
>         *Subject:* RE: Using CHOOSE to control image in region-body
>
>         I can think of two possibilities off the top of my head: The
>         value is a lowercase Y, or there is whitespace present. Try
>         normalize-space(send-fax)='Y' instead.
>          
>         Eric Amick
>         Legislative Computer Systems
>         Office of the Clerk
>          
>
>         ------------------------------------------------------------------------
>         *From:* Steffanina, Jeff [mailto:Jeff.Steffanina <at> marriott.com]
>         *Sent:* Tuesday, October 7, 2008 14:54
>         *To:* fop-users <at> xmlgraphics.apache.org
>         *Subject:* Using CHOOSE to control image in region-body
>
>
>         FOP 0.95 / Redhat Linux / Java 1.5
>
>         When the tag "send-fax" does not exist print the lilly, when
>         send-fax=Y, print the pebble.  I always get the Lilly.  Can
>         you determine why?
>
>         <xsl:choose>
>           <xsl:when test="./send-fax='Y'">
>                <!--   region-before means region before the body(top
>         1/3 of folio   -->
>                <fo:region-before extent="3.0in"
>                             background-repeat="no-repeat"
>                             margin-top=".5in"
>                            
>         background-image="url('java/images/Pebble.jpg')"
>                             background-position-vertical="bottom"
>                             display-align="after" />
>           </xsl:when>
>           <xsl:otherwise>
>               <fo:region-before extent="3.0in"
>                             background-repeat="no-repeat"
>                             margin-top=".5in"
>                            
>         background-image="url('java/images/Lilly.jpg')"
>                             background-position-vertical="bottom"
>                             display-align="after" />
>           </xsl:otherwise>
>         </xsl:choose>
>
>
>
>         */Jeff/*
>
Picon

Re: Using CHOOSE to control image in region-body

Steffanina, Jeff a écrit :
>
> FOP 0.95 / Redhat Linux / Java 1.5
>
> When the tag "send-fax" does not exist print the lilly, when 
> send-fax=Y, print the pebble.  I always get the Lilly.  Can you 
> determine why?
>
"tag", do you mean an attribute of the current element ?
I would write
test="@sendfax='Y'"

I don't think I ever used a syntax like ./
I used ../
or nothing
but can't understand what this is meant for (of course this can simply 
be a syntax I'm not used to).
Pete Allison | 7 Oct 22:08
Picon
Favicon

RE: Using CHOOSE to control image in region-body

Me too also...

I have used ../SOME_NODE_NAME or variations of this.

The current node can be abreviated "." 

It's almost like your trying to access the value of attribute named "send-fax" for the current node, not the
value of the element <send‑fax>.

-----Original Message-----
From: Jean-François El Fouly [mailto:jean-francois <at> elfouly.fr] 
Sent: Tuesday, October 07, 2008 3:03 PM
To: fop-users <at> xmlgraphics.apache.org
Subject: Re: Using CHOOSE to control image in region-body

Steffanina, Jeff a écrit :
>
> FOP 0.95 / Redhat Linux / Java 1.5
>
> When the tag "send-fax" does not exist print the lilly, when 
> send-fax=Y, print the pebble.  I always get the Lilly.  Can you 
> determine why?
>
"tag", do you mean an attribute of the current element ?
I would write
test="@sendfax='Y'"

I don't think I ever used a syntax like ./ I used ../ or nothing but can't understand what this is meant for (of
course this can simply be a syntax I'm not used to).

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe <at> xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help <at> xmlgraphics.apache.org
Jay Bryant | 7 Oct 23:57

Re: Using CHOOSE to control image in region-body

Hi, Jeff,

I whipped up a small test to show how to solve your problem. Here's the 
contents of the (very simple) input XML file:

<test>
  <send-fax>Y</send-fax>
</test>

Here's the (also very simple XSL file):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="test">
    <xsl:choose>
      <xsl:when test="send-fax = 'Y'">
        <xsl:message>Found it</xsl:message>
      </xsl:when>
      <xsl:otherwise>
        <xsl:message>No joy</xsl:message>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>

When I run that XML file against that XSL file, I get "found it" on my 
command line.

I bet you can extrapolate from there how to get the XSL-FO content you want. 
If not, let me know and I'll try to help further.

HTH

Jay Bryant

----- Original Message ----- 
From: "Steffanina, Jeff" <Jeff.Steffanina <at> marriott.com>
To: <fop-users <at> xmlgraphics.apache.org>
Sent: Tuesday, October 07, 2008 1:54 PM
Subject: Using CHOOSE to control image in region-body

FOP 0.95 / Redhat Linux / Java 1.5

When the tag "send-fax" does not exist print the lilly, when send-fax=Y,
print the pebble.  I always get the Lilly.  Can you determine why?

<xsl:choose>
  <xsl:when test="./send-fax='Y'">
       <!--   region-before means region before the body(top 1/3 of
folio   -->
       <fo:region-before extent="3.0in"
                    background-repeat="no-repeat"
                    margin-top=".5in"
                    background-image="url('java/images/Pebble.jpg')"
                    background-position-vertical="bottom"
                    display-align="after" />
  </xsl:when>
  <xsl:otherwise>
      <fo:region-before extent="3.0in"
                    background-repeat="no-repeat"
                    margin-top=".5in"
                    background-image="url('java/images/Lilly.jpg')"
                    background-position-vertical="bottom"
                    display-align="after" />
  </xsl:otherwise>
</xsl:choose>

Jeff
Pascal Sancho | 8 Oct 09:19
Picon

RE: Using CHOOSE to control image in region-body

Hi,

If you read  "<send-fax>Y</send-fax>", it is possible that there are some extra invisible charaters.
If you want, you can investigate with string-length() and if >1, try to determine (then discard)
unexpected characters.

However, I can imagine 2 simple solutions that should help:
First solution should be to use normalize-space() function, like this:
<xsl:when test="normalize-space(send-fax)='Y'">...

Another solution consists in using contains() function:
<xsl:when test="contains(send-fax,'Y')">...

Just for curiosity, what XSLT engine do you use?

HTH,
Pascal

> -----Message d'origine-----
> De : Jay Bryant [mailto:jay <at> bryantcs.com] 
> Envoyé : mardi 7 octobre 2008 23:58
> 
> Hi, Jeff,
> 
> I whipped up a small test to show how to solve your problem. 
> Here's the 
> contents of the (very simple) input XML file:
> 
> <test>
>   <send-fax>Y</send-fax>
> </test>
> 
> Here's the (also very simple XSL file):
> 
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <xsl:stylesheet version="2.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>   <xsl:template match="test">
>     <xsl:choose>
>       <xsl:when test="send-fax = 'Y'">
>         <xsl:message>Found it</xsl:message>
>       </xsl:when>
>       <xsl:otherwise>
>         <xsl:message>No joy</xsl:message>
>       </xsl:otherwise>
>     </xsl:choose>
>   </xsl:template>
> </xsl:stylesheet>
> 
> When I run that XML file against that XSL file, I get "found 
> it" on my 
> command line.
> I bet you can extrapolate from there how to get the XSL-FO 
> content you want. 
> If not, let me know and I'll try to help further.
> HTH
> 
> Jay Bryant
> 
> ----- Original Message ----- 
> From: "Steffanina, Jeff" <Jeff.Steffanina <at> marriott.com>
> To: <fop-users <at> xmlgraphics.apache.org>
> 
> FOP 0.95 / Redhat Linux / Java 1.5
> When the tag "send-fax" does not exist print the lilly, when 
> send-fax=Y,
> print the pebble.  I always get the Lilly.  Can you determine why?
> 
> <xsl:choose>
>   <xsl:when test="./send-fax='Y'">
>        <!--   region-before means region before the body(top 1/3 of
> folio   -->
>        <fo:region-before extent="3.0in"
>                     background-repeat="no-repeat"
>                     margin-top=".5in"
>                     background-image="url('java/images/Pebble.jpg')"
>                     background-position-vertical="bottom"
>                     display-align="after" />
>   </xsl:when>
>   <xsl:otherwise>
>       <fo:region-before extent="3.0in"
>                     background-repeat="no-repeat"
>                     margin-top=".5in"
>                     background-image="url('java/images/Lilly.jpg')"
>                     background-position-vertical="bottom"
>                     display-align="after" />
>   </xsl:otherwise>
> </xsl:choose>
> 
> Jeff
Steffanina, Jeff | 8 Oct 13:38

RE: Using CHOOSE to control image in region-body


My Friends,
Thank you for the many suggestions!  I have tried them all and my issue, as suggested by Jean-Francois
appears to be related to the fact that my xml tag "send-fax" is not a direct child of the node I am processing. 
Instead, it a "remote descendant".  Therefore, I used the following code:

		<xsl:when test="count(//send-fax = 0">

I will have to review some docs to clearly understand the "remote descendant" issue.  It points out that I
should have done a better job in my original template design.

Thanks for all the input!

Jeff 

-----Original Message-----
From: Pascal Sancho [mailto:pascal.sancho <at> takoma.fr] 
Sent: Wednesday, October 08, 2008 3:20 AM
To: fop-users <at> xmlgraphics.apache.org
Subject: RE: Using CHOOSE to control image in region-body

Hi,

If you read  "<send-fax>Y</send-fax>", it is possible that there are some extra invisible charaters.
If you want, you can investigate with string-length() and if >1, try to determine (then discard)
unexpected characters.

However, I can imagine 2 simple solutions that should help:
First solution should be to use normalize-space() function, like this:
<xsl:when test="normalize-space(send-fax)='Y'">...

Another solution consists in using contains() function:
<xsl:when test="contains(send-fax,'Y')">...

Just for curiosity, what XSLT engine do you use?

HTH,
Pascal

> -----Message d'origine-----
> De : Jay Bryant [mailto:jay <at> bryantcs.com] 
> Envoyé : mardi 7 octobre 2008 23:58
> 
> Hi, Jeff,
> 
> I whipped up a small test to show how to solve your problem. 
> Here's the 
> contents of the (very simple) input XML file:
> 
> <test>
>   <send-fax>Y</send-fax>
> </test>
> 
> Here's the (also very simple XSL file):
> 
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <xsl:stylesheet version="2.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>   <xsl:template match="test">
>     <xsl:choose>
>       <xsl:when test="send-fax = 'Y'">
>         <xsl:message>Found it</xsl:message>
>       </xsl:when>
>       <xsl:otherwise>
>         <xsl:message>No joy</xsl:message>
>       </xsl:otherwise>
>     </xsl:choose>
>   </xsl:template>
> </xsl:stylesheet>
> 
> When I run that XML file against that XSL file, I get "found 
> it" on my 
> command line.
> I bet you can extrapolate from there how to get the XSL-FO 
> content you want. 
> If not, let me know and I'll try to help further.
> HTH
> 
> Jay Bryant
> 
> ----- Original Message ----- 
> From: "Steffanina, Jeff" <Jeff.Steffanina <at> marriott.com>
> To: <fop-users <at> xmlgraphics.apache.org>
> 
> FOP 0.95 / Redhat Linux / Java 1.5
> When the tag "send-fax" does not exist print the lilly, when 
> send-fax=Y,
> print the pebble.  I always get the Lilly.  Can you determine why?
> 
> <xsl:choose>
>   <xsl:when test="./send-fax='Y'">
>        <!--   region-before means region before the body(top 1/3 of
> folio   -->
>        <fo:region-before extent="3.0in"
>                     background-repeat="no-repeat"
>                     margin-top=".5in"
>                     background-image="url('java/images/Pebble.jpg')"
>                     background-position-vertical="bottom"
>                     display-align="after" />
>   </xsl:when>
>   <xsl:otherwise>
>       <fo:region-before extent="3.0in"
>                     background-repeat="no-repeat"
>                     margin-top=".5in"
>                     background-image="url('java/images/Lilly.jpg')"
>                     background-position-vertical="bottom"
>                     display-align="after" />
>   </xsl:otherwise>
> </xsl:choose>
> 
> Jeff

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe <at> xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help <at> xmlgraphics.apache.org
Andreas Delmelle | 13 Oct 21:39
Picon

Re: Using CHOOSE to control image in region-body

On Oct 8, 2008, at 13:38, Steffanina, Jeff wrote:

Hi,

FWIW, a small performance hint:

> My Friends,
> Thank you for the many suggestions!  I have tried them all and my  
> issue, as suggested by Jean-Francois appears to be related to the  
> fact that my xml tag "send-fax" is not a direct child of the node I  
> am processing.  Instead, it a "remote descendant".  Therefore, I  
> used the following code:
>
> <xsl:when test="count(//send-fax = 0">

Seems better to use:

<xsl:when test="not(//send-fax)">

Why?
The node-set is implicitly converted to a boolean, which the  
processor (if intelligent enough) can evaluate as "true" as soon as  
the first such node is encountered. The expression "count(//send- 
fax)", OTOH, is more likely to trigger a complete tree-traversal  
starting at the context node. IIC, using a boolean would only mean a  
complete traversal iff the node-set is also empty (= false)

Cheers

Andreas
Steffanina, Jeff | 13 Oct 21:54

RE: Using CHOOSE to control image in region-body


Andreas
I greatly appreciate the suggestion!  I will make the change!

Jeff 

-----Original Message-----
From: Andreas Delmelle [mailto:andreas.delmelle <at> telenet.be] 
Sent: Monday, October 13, 2008 3:40 PM
To: fop-users <at> xmlgraphics.apache.org
Subject: Re: Using CHOOSE to control image in region-body

On Oct 8, 2008, at 13:38, Steffanina, Jeff wrote:

Hi,

FWIW, a small performance hint:

> My Friends,
> Thank you for the many suggestions!  I have tried them all and my  
> issue, as suggested by Jean-Francois appears to be related to the  
> fact that my xml tag "send-fax" is not a direct child of the node I  
> am processing.  Instead, it a "remote descendant".  Therefore, I  
> used the following code:
>
> <xsl:when test="count(//send-fax = 0">

Seems better to use:

<xsl:when test="not(//send-fax)">

Why?
The node-set is implicitly converted to a boolean, which the  
processor (if intelligent enough) can evaluate as "true" as soon as  
the first such node is encountered. The expression "count(//send- 
fax)", OTOH, is more likely to trigger a complete tree-traversal  
starting at the context node. IIC, using a boolean would only mean a  
complete traversal iff the node-set is also empty (= false)

Cheers

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe <at> xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help <at> xmlgraphics.apache.org

Gmane