You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Smith, David" <Sm...@DNB.com> on 2000/11/01 20:40:17 UTC

Error with Variable

Hi
I'm getting following error in while performing XSLT transformation.  Can
not convert #RTREEFRAG to a NodeList!
Does anybody have any ideas. 
I have enclosed the xsl fragment that is being used, as well as the two xml
fragments that are being referenced.
The whole thing is going on inside a for-each loop:
<xsl:for-each select="CONTENT/CONTENTAREA/DYNAMIC/AVAILRPTS/AVAILRPT">
 
XSL:
<xsl:variable name="valDESC"><xsl:value-of select="RPT_NME"/></xsl:variable>
<xsl:if test="$valDESC[.!='']">
	<span class="body">
	<xsl:value-of select="//STATIC/DESCS/DESC[@ NAME=$valDESC]"/></span>
	</xsl:if>

XML:
<AVAILRPTS>
					<AVAILRPT>
						<RPT_NME>Quick Check
Report</RPT_NME>
						<PRICE>6.00</PRICE>
						<CRCY_CD>USD</CRCY_CD>
						<!-- (GDP doc has table of
ISO curreny codes)-->
						<CART NAME="ADD_TO_CART">
							<CURL NAME="CART">
								<DNBREF
NAME="CART">
	
<TEMPLATEPATH/>
	
<SEGMENTNAME/>
								</DNBREF>
							</CURL>
							<IMAGE>
								<SRC>
	
<DNBPATH>
	
<PATH>ImagesPath</PATH>
	
<LANG>1012</LANG>
	
<NAME>addtocarticon.gif</NAME>
	
</DNBPATH>
								</SRC>
								<ALT>Add to
Cart</ALT>
							</IMAGE>
						</CART>
					</AVAILRPT>



<DESCS>					
	<DESC NAME="Business Verification Report">Verify a companys
existence and learn of the precence of public filings.</DESC>
	<DESC NAME="Quick Check Report">Efficiently pre-screen prospects or
obtain a quick overview on clients.</DESC>
	<DESC NAME="D&amp;B Business Information Report">Understand a firm's
oveerall profile - from its background principals to its financial, legal
and payment record.</DESC>
</DESCS>




Please tell me if you have encountered this before.



Dave Smith

www.dnb.com
973.605.6392(PH)
smithD5@dnb.com




Re: Error with Variable

Posted by Gary L Peskin <ga...@firstech.com>.
"Smith, David" wrote:
> I'm getting following error in while performing XSLT transformation.  Can
> not convert #RTREEFRAG to a NodeList!
> Does anybody have any ideas.
> I have enclosed the xsl fragment that is being used, as well as the two xml
> fragments that are being referenced.
> The whole thing is going on inside a for-each loop:
> <xsl:for-each select="CONTENT/CONTENTAREA/DYNAMIC/AVAILRPTS/AVAILRPT">
> 
> XSL:
> <xsl:variable name="valDESC"><xsl:value-of select="RPT_NME"/></xsl:variable>
> <xsl:if test="$valDESC[.!='']">
>         <span class="body">
>         <xsl:value-of select="//STATIC/DESCS/DESC[@ NAME=$valDESC]"/></span>
>         </xsl:if>

David --

$valDESC is a result tree fragment (RTF) as defined in the XSLT
Recommendation section 11.1.  As stated there, ".. . it is not permitted
to use the /, //, and [] operators on result tree fragments."   You're
getting the error because of your use of the [] operator in the test
attribute of your xsl:if element.

You have a few choices, depending on what you want to do.
1.  Your current setup creates a node-set containing all of the RPT_NME
elements.  The xsl:value-of element creates a text node in the result
tree consisting of the string value of the node-set which is the string
value of the _first_ node in the node-set.  In this case, $valDESC will
be a result tree fragment that looks like this:

	|-- root
            |-- Single text node consisting of string content of RPT_NME
element.

If this is what you want, Xalan does offer an extension function called
nodeset that will convert your RTF to a node-set containing a single
root node as shown above.  If you have questions about using this
extension, please ask.

To accomplish your task, what you probably want to do is:
  <xsl:variable name="valDESC" select="RPT_NME"/>

You may run into other problems after you get this working.  If you need
help, come back.

Gary