You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by CP Hennessy <CP...@iname.com> on 2003/03/30 13:57:13 UTC

problem with Xalan & XSLT

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>	


Re: problem with Xalan & XSLT

Posted by CP Hennessy <CP...@iname.com>.
My bad!
I did not read the error message correctly. I've solved my problem by use 
"node-set" instead of "nodeset" :)

Thanks for your help,
CP

On Monday 31 March 2003 10:21, CP Hennessy wrote:
> Hi Mark,
> 	OK, I've tried using this but I get the error :
> XalanXPathException: The specified function is not available:
> http://exslt.org/common:nodeset (file:///home/yamed/tmp/dtd/xvt.xsl,
>  line 70, column 87)
>
> To solve this I think that I need to have common.dtd ( or .mod ) in the
> local directory, but when I download exsl.zip from exsl.org it does not
> contain such a file. What am I doing wrong ?
>
> Thanks
> CPH
>
> On Monday 31 March 2003 01:59, Mark Weaver wrote:
> > Try:
> >
> >  <xsl:transform
> > 	...
> > 	xmlns:exsl="http://exslt.org/common"
> > 	extension-element-prefixes="exsl"
> >
> > Then:
> >
> > select="exsl:node-set($listTitles)/li[$rowPos = @row]"
> >
> > Mark
> >
> > > -----Original Message-----
> > > From: CP Hennessy [mailto:CP.Hennessy@iname.com]
> > > Sent: 30 March 2003 12:57
> > > To: xalan-c-users@xml.apache.org
> > > Subject: problem with Xalan & XSLT
> > >
> > >
> > > 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>


Re: problem with Xalan & XSLT

Posted by CP Hennessy <CP...@iname.com>.
Hi Mark,
	OK, I've tried using this but I get the error :
XalanXPathException: The specified function is not available: 
http://exslt.org/common:nodeset (file:///home/yamed/tmp/dtd/xvt.xsl,
 line 70, column 87)

To solve this I think that I need to have common.dtd ( or .mod ) in the local
directory, but when I download exsl.zip from exsl.org it does not contain
such a file. What am I doing wrong ?

Thanks
CPH

On Monday 31 March 2003 01:59, Mark Weaver wrote:
> Try:
>
>  <xsl:transform
> 	...
> 	xmlns:exsl="http://exslt.org/common"
> 	extension-element-prefixes="exsl"
>
> Then:
>
> select="exsl:node-set($listTitles)/li[$rowPos = @row]"
>
> Mark
>
> > -----Original Message-----
> > From: CP Hennessy [mailto:CP.Hennessy@iname.com]
> > Sent: 30 March 2003 12:57
> > To: xalan-c-users@xml.apache.org
> > Subject: problem with Xalan & XSLT
> >
> >
> > 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>


RE: problem with Xalan & XSLT

Posted by Mark Weaver <ma...@npsl.co.uk>.
Try:

 <xsl:transform
	...
	xmlns:exsl="http://exslt.org/common"
	extension-element-prefixes="exsl"

Then:

select="exsl:node-set($listTitles)/li[$rowPos = @row]"

Mark

> -----Original Message-----
> From: CP Hennessy [mailto:CP.Hennessy@iname.com]
> Sent: 30 March 2003 12:57
> To: xalan-c-users@xml.apache.org
> Subject: problem with Xalan & XSLT
> 
> 
> 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>	
> 
>