Page 1 of 1

Allegedly empty sequence in xsl:number select attribute

Posted: Tue Sep 11, 2018 10:47 pm
by Vince42
I have an XML source that looks shortened like this

Code: Select all


<sheetData>
<row r="1" spans="1:3" x14ac:dyDescent="0.2">
<c r="A1" s="4" t="s">
<v>0</v>
</c>
<c r="B1" s="5" t="s">
<v>1</v>
</c>
<c r="C1" s="5" t="s">
<v>2</v>
</c>
</row>
<row r="2" spans="1:3" x14ac:dyDescent="0.2">
<c r="A2" s="2">
<v>1</v>
</c>
<c r="B2" s="3" t="s">
<v>3</v>
</c>
<c r="C2" s="3" t="s">
<v>12</v>
</c>
</row>
<row r="3" spans="1:3" x14ac:dyDescent="0.2">
<c r="A3" s="2">
<v>2</v>
</c>
<c r="B3" s="3" t="s">
<v>4</v>
</c>
<c r="C3" s="3" t="s">
<v>13</v>
</c>
</row>
<row r="4" spans="1:3" x14ac:dyDescent="0.2">
<c r="A4" s="2">
<v>3</v>
</c>
<c r="B4" s="3" t="s">
<v>5</v>
</c>
<c r="C4" s="3" t="s">
<v>14</v>
</c>
</row>
</sheetData>
I also have a parameter that specifies a range ("A1:B2") and I am trying to calculate the starting and ending row and column with the following (also shortened) XSL:

Code: Select all


<xsl:variable name="startCellAddress" select="substring-before(.,':')"/>
<xsl:variable name="endCellAddress" select="substring-after(.,':')"/>
<xsl:variable name="startCell" select="$worksheet/xl:worksheet/xl:sheetData//xl:c[@r=$startCellAddress]"/>
<xsl:variable name="endCell" select="$worksheet/xl:worksheet/xl:sheetData//xl:c[@r=$endCellAddress]"/>
<xsl:variable name="startRow">
<xsl:number select="$startCell" count="xl:row"/>
</xsl:variable>
<xsl:variable name="startColumn">
<xsl:number select="$startCell" count="xl:c"/>
</xsl:variable>
<xsl:variable name="endRow">
<xsl:number select="$endCell" count="xl:row"/>
</xsl:variable>
<xsl:variable name="endColumn">
<xsl:number select="$endCell" count="xl:c"/>
</xsl:variable>
Now comes the weird part: the XSL correctly retrieves the startCellAddress, endCellAddress, the startCell and endCell, it counts correctly the startRow and startColumn, but the moment it reaches the calculation of the endRow, it throws an error

Code: Select all

An empty sequence is not allowed as the @select attribute of xsl:number
.

Any idea what might go wrong here?

Re: Allegedly empty sequence in xsl:number select attribute

Posted: Wed Sep 12, 2018 9:24 am
by Radu
Hi,

This probably means that the XPath used on the xsl:number count="xl:c" will not match anything in a certain context.
But it's hard to tell what the problem is without having a sample XML + XSLT to test with.

Regards,
Radu

Re: Allegedly empty sequence in xsl:number select attribute

Posted: Thu Sep 13, 2018 11:18 am
by Vince42
You are right - I meanwhile found the error by debugging the XSL template step by step: it was not this case, but another context, where it retrieved a non-existing node.

Thank you very much!