Allegedly empty sequence in xsl:number select attribute
Posted: Tue Sep 11, 2018 10:47 pm
I have an XML source that looks shortened like this
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:
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 .
Any idea what might go wrong here?
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>
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>
Code: Select all
An empty sequence is not allowed as the @select attribute of xsl:number
Any idea what might go wrong here?