Hi,
I'm trying to work on an XSLT to transform an OpenOffice document
with values in rows of a table with the first column contains a title and the
second column contains a value associated with the title. ( For various
reasons I cannot actually put more structure than this onto the data ).
Xalan version 1.4.0
Xerces version 2.0.0
With the xslt ( written by someone else ) from below I'm getting the error :
XObjectInvalidConversionException: Cannot convert a #RESULT_TREE_FRAG to a
node set. (, line -1, column -1)
which seems to be caused by the line :
<xsl:variable name="ltItem"
select="$listTitles/li[$rowPos = @row]"/>
Thanks for any help,
CPH
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:office="http://openoffice.org/2000/office"
xmlns:style="http://openoffice.org/2000/style"
xmlns:text="http://openoffice.org/2000/text"
xmlns:table="http://openoffice.org/2000/table"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:number="http://openoffice.org/2000/datastyle"
xmlns:chart="http://openoffice.org/2000/chart"
xmlns:dr3d="http://openoffice.org/2000/dr3d"
xmlns:form="http://openoffice.org/2000/form"
xmlns:script="http://openoffice.org/2000/script"
version="1.1">
<xsl:strip-space elements="*"/>
<xsl:template match="/office:document-content/office:body">
<xsl:variable name="listTitles">
<li row="1">name</li>
<li row="2">info</li>
<li row="3">action</li>
<li row="4">supplier</li>
<li row="5">ooh</li>
<li row="6">contact</li>
<li row="7">position</li>
<li row="8">label</li>
<li row="9">pc</li>
</xsl:variable>
<products>
<xsl:for-each select="table:table">
<product>
<xsl:for-each select="table:table-row">
<!-- if the first cell in the row doesn't contain text,
ignore it -->
<xsl:variable name="cellTitle"
select="normalize-space(table:table-cell[1]//*)"/>
<xsl:variable name="cellData"
select="normalize-space(table:table-cell[2]//*)"/>
<xsl:variable name="rowPos" select="position()"/>
<xsl:if test="$cellTitle">
<!-- index into the above row table for the element
name -->
<xsl:variable name="ltItem"
select="$listTitles/li[$rowPos = @row]"/>
<xsl:element name="xalan:nodeset($ltItem)">
<xsl:value-of select="$cellData"/>
</xsl:element>
</xsl:if>
</xsl:for-each>
</product>
</xsl:for-each>
</products>
</xsl:template>
</xsl:transform>