Subject: [xsl] Define internal xsl variable From: "Susanne Wunsch" <xsl@xxxxxxxxxxxxxxxxx> Date: Wed, 5 Oct 2011 10:01:54 +0200 |
Hello, I'm Susanne and did already some xsl transformations before. For now I try to define an internal xsl variable but the xpath expression doesn't work so far. (The current xsl approach is shown below.) The 'origin' variable should be mapped into the following node set (in the 'spannedCells' variable): <t:data>1</t:data> <t:data>2 3</t:data> <t:data>4 5 6</t:data> <t:data>7</t:data> It shows occupied cells including the "spanned" ones. I think that some recursive design should be possible but I just didn't find how to start in this case. I would be very glad about any hint. Full xsl file follows: ------------------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="http://www.example.org/test" version="2.0"> <xsl:template name="main"> <xsl:variable name="origin" as="node()*"> <t:cell>foo</t:cell> <t:cell span="2">bar</t:cell> <t:cell span="3">baz</t:cell> <t:cell>test</t:cell> </xsl:variable> <xsl:variable name="SpannedCells" as="node()*"> <t:data>1</t:data> <xsl:for-each select="$origin[position() > 1]"> <xsl:variable name="PreviousValue" select="xs:integer(max(preceding::t:data/text()))"/> <xsl:variable name="MaxValue" select="if (./@span) then ($PreviousValue + 1 + @span) else ($PreviousValue + 1)"/> <t:data> <xsl:value-of select="($PreviousValue + 1) to $MaxValue"/> </t:data> </xsl:for-each> </xsl:variable> <xsl:message select="$SpannedCells"/> </xsl:template> </xsl:stylesheet> ------------------------------------------------------------------------ Thanks and kind regards... Susanne
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] max string-length for con, Andrew Welch | Thread | Re: [xsl] Define internal xsl varia, Michael Kay |
Re: [xsl] max string-length for con, Dimitre Novatchev | Date | Re: [xsl] max string-length for con, Michel Hendriksen |
Month |