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

RE: xslt node-set variable transversal

Subject: RE: xslt node-set variable transversal
From: "Kyle Partridge" <kpartridge@xxxxxxxxxxxx>
Date: Tue, 30 Mar 2004 16:58:02 -0500
xml transversal
Andreas,

Thank you so much for your response!!

I know that all the preceding and following siblings of "region" will be
available from inside the template I'm calling.  But the problem is, I
ONLY want to process "region" nodes that belong within the column I'm
processing.

For example, let's say I want to turn my xml document into a PDF
document that is 439pt wide (8.5 inches).

I could easily have this, as the xml document <regions>:

<xsl:variable name="useable-page-width">493</xsl:variable>
<regions>
	<region left="36pt"..............etc
	<region left="120pt".............etc
	<region left="630pt".............etc
	<region left="230pt".............etc
</regions>

So, now, if I just do a template that matches on regions, for example,
and I get to region 4, and I want to find the space-before to draw that
region correctly on the page, if I don't re-screen all the
preceding-siblings, I'll get region 3 - which is outside of the column
I'm processing.

<xsl:template match:"ws:regions">
	<xsl:apply-templates select="ws:region[@left&gt;0 and
(@left+@width)&lt;number($useable-page-width)]"/>
</xsl:template>

<xsl:template match="ws:region">
	<!-- to get space-before for a region, I 
	need to subtract the bottom of the previous region
	from the top of this one - but I want to *ignore*
	any regions that don't belong in this space... -->

	<xsl:variable name="prev-region"
select="preceding-sibling::ws:region[@left&gt;0 and (@left+@width)&lt;
number($useable-page-width)][1]"/>
	
	<fo:block space-before={number(($prev-region/@top +
$prev-region/@height)-@top)){$units}}...............etc.

</xsl:template>

What I don't like about this is, every time I want to process a region I
have to re-filter all the nodes that don't belong in the column I care
about.  Is that the only way?

Thanks so much, again for your help.

KP

Andreas wrote:

<snip>
However, there seems to be something rather awkward about the structure

<xsl:for-each select="$nodes">
  ...
  <xsl:apply-templates select="." mode="different-mode">
    <xsl:with-param name="pprec" select="preceding-sibling::*" />
    <xsl:with-param name="pfoll" select="following-sibling::*" />
  </xsl:apply-templates>

</xsl:for-each>

which seems more or less what you're trying to do.

The reason for my thinking so is the fact that the preceding- and
following-sibling axes will *per se* be available from within the
matching
template, since the context node will be changed by the
apply-templates --I'm absolutely dazzled as to why you would want to
pass
these in as parameters...

The above just needs to become:
<xsl:apply-templates select="$nodes">
  <xsl:with-param name="pparam" select="expr" />
</xsl:apply-templates>

where the param is used to collect data which is easily accessible from
the
context surrounding the apply-templates, but won't be too easily
reachable
from within the context of the matching template.
</snip>

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.