xsl-list
[Top] [All Lists]

Re: [xsl] Parameter Scope

2007-06-12 07:52:42
On 6/12/07, Matt <puskas(_dot_)duck(_at_)gmail(_dot_)com> wrote:
Thanks Andrew, I didn't want to put too much info in as to cloud the issue.

I'm quite happy with the structure - other than it appears there is a
lack of way of communucating between the peer templates (pageLayouts)
, and I wondered if I'd missed a trick.

 I was thinking of including an extra template in between the root and
the pageLayouts, which would be recursively called from pageLayout,
and your suggestion is encouraging me down that route.

The structure is quite important as I need to map it all back on to a
database design which allows the XSL to be autogenerated eventually.

ie.

<xsl:template match="/">
  <xsl:appy-templates mode="report" />
</xsl:template>

<xsl:template mode="report">
  <xsl:param name="pageNo" select="'1'"/>

 <xsl:apply-templates mode="pageLayout1">
    <xsl:with-param name="pageNo" select="'$pageNo'"/>
 </xsl:apply-templates>

 <xsl:apply-templates mode=pageLayout2">
   <xsl:with-param name="pageNo" select="'$pageNo'"/>
 </xsl:apply-templates>

</xsl:template>

An alternative way is:

<xsl:variable name="pageLayout1">
<xsl:apply-templates mode="pageLayout1">
  <xsl:with-param name="pageNo" select="'$pageNo'"/>
</xsl:apply-templates>
</xsl:variable>

<xsl:variable name="pageLayout2">
<xsl:apply-templates mode="pageLayout2">
  <xsl:with-param name="pageNo" select="'count($pageLayout1//pages)'"/>
</xsl:apply-templates>
</xsl:variable>

<xsl:copy-of select="$pageLayout1"/>
<xsl:copy-of select="$pageLayout2"/>

This way you can access any part of $pageLayout1 from any subsequent
part of the processing, in this case to count the number of pages.

Another alternative is to not worry about page numbers at that point
(if thats possible) and just add them later eg:

<xsl:apply-templates select="$pageLayout1|$pageLayout2" mode="pageNumber"/>

...with the identity template and another to add the actual page number.

cheers
andrew

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>