Subject: RE: [xsl] xslt node-set variable transversal From: "Kyle Partridge" <kpartridge@xxxxxxxxxxxx> Date: Tue, 30 Mar 2004 16:58:02 -0500 |
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>0 and (@left+@width)<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>0 and (@left+@width)< 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] xslt node-set variable tr, Andreas L. Delmelle | Thread | RE: [xsl] xslt node-set variable tr, Andreas L. Delmelle |
Re: [xsl] Re:Help needed in recursi, Sridhar Anupindi | Date | RE: [xsl] new thread... difference , Michael Kay |
Month |