[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Passing document fragments as nodsets

Subject: Re: Passing document fragments as nodsets
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 7 Jul 2003 11:56:38 +0100
node set parameter
Hi Simon,

> This is the test that fails every time, but I know the node set
> contains one node. Is the test correct for erroring if the set is
> null?
>
> <xsl:if test="not($text-nodes)">
>     <xsl:message terminate="yes">
>         Template footer-text-rows was called without
>         a value passed in text-nodes. Check the code!
>     </xsl:message>
> </xsl:if>

That's the correct test for seeing if $text-nodes is empty or not; you
should get the error message if $text-nodes is empty.

When footer-text-rows is called with:

>       <xsl:if test="$text-node-count &gt; 0">
>         <xsl:call-template name="footer-text-rows">
>           <xsl:with-param name="node-set" select="$text-nodes" />
>         </xsl:call-template>
>       </xsl:if>

then $text-nodes will always be empty, since you're only passing in a
value for the $node-set parameter and the $text-nodes parameter
defaults to the empty node set.

When you call it in:

>   <!-- Center footer section: table generating template -->
>   <xsl:template name="footer-center">
>     <xsl:param name="text-nodes" select="/.." />
> 
>     <table>
>       <xsl:call-template name="footer-text-rows">
>         <xsl:with-param name="text-nodes" select="$text-nodes" />
>       </xsl:call-template>
>     </table>
>   </xsl:template>

then the value of $text-nodes depends on the value of $text-nodes in
the footer-center template, which depends on what:

>           <xsl:call-template name="footer-center">
>             <xsl:with-param name="text-nodes">
>               <xsl:value-of select="xalan:nodeset(.)/text[@position =
> 'center']" />
>             </xsl:with-param>
>           </xsl:call-template>

is doing; since I don't have the source document I can't tell whether
$text-nodes will actually hold anything here.

By the way, I doubt that your "counter" template is doing what you
want it to do, since the test:

  $node-set[$count] = last()

is true if the string value of the node in $node-set at the position
of $count is equal to the number of nodes currently being processed,
which is probably always going to be 1, assuming that your XML
document looks like:

<?xml version="1.0"?>
<footer>
  ...
</footer>

If you want to count how many nodes are in a node set, you should use
the count() function:

  count($node-set)

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.