Bart,

Unless your extension needs to support the NodeList interface for some other
purpose, it may be easier ( and faster code) to implement a DTM interface.
For an example look at the latest SQL Extension code (today's checkin)
The new code has greatly reduced the code complexity of the original
extension code and may prove to be a simple port.

Regards
JohnG

"Bart W.Jenkins" wrote:

> Gary,
>   First, thanks for being so patient...we are investing heavily in XML / XSL
> and making sure we know this technology thoroughly is critical.  And I agree
> with you...the first form is easier.
>
> All right...more questions!
>
> Prior to the Xalan versions that use DTM (specifically version 1_2_1),
> regardless whether my JAVA code returned a nodelist or a nodeset, I could
> then use the Xpath form we have been discussing:
>
> $var/node1/node2/...
>
> in my XSL, but when I try this with Xalan 1_2_2_D7, (one that uses DTM), I
> get the following error:
>
> XSLT Error (javax.xml.transform.TransformerException): Can not convert
> #UNKNOWN    (org.apache.xml.dtm.ref.DTMNodeList) to a NodeList!
>
> In the docs for version 1_2_2_D7, in the description for DTM, it states:
> "For the convenience of user-written extensions, a proxy mechanism presents
> the contents of the DTM as a read-only subset of the DOM"
>
> How do I make use of this proxy?  My error above suggests that this
> conversion is not happening for me automatically.  Any pointers?  Or, should
> I drop back to v 1_2_1?
>
> Bart Jenkins, CTO
> Globeflow SA
> Cardenal Marcelo Spinola 2, D1, Planta 6
> 28016 Madrid, Spain
> telephone: +34 667 65 10 75
> mailto:[EMAIL PROTECTED]
>
>
> -----Original Message-----
> From: Gary L Peskin [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 30, 2001 6:25 PM
> To: [EMAIL PROTECTED]
> Subject: Re: UPDATE: How to correctly process, via Xpath,
> result-tree-fragments returned by JAVA extensions? More questions...
>
> "Bart W.Jenkins" wrote:
> >
> > Gary,
> >   Ok.  I got your sample to work also and now I know why...
> >   There are 2 things different with your sample...
> >
> > 1.  You use the xsl:variable option in which you place the select as the
> > attribute in the xsl:variable element name instead of in the element body.
> > That is, you used:
> >
> >     <xsl:variable name="myRTF" select='Ext:getMyXMLStr()'/>
> >
> > and this works, however...
> >
> >       <xsl:variable name="myRTF">
> >           <xsl:value-of select='Ext:getMyXMLStr()'/>
> >         </xsl:variable>
> >
> > does NOT, and I thought the two forms of declaration were equivalent.
>
> No, they're different.  See http://www.w3.org/TR/xslt#variable-values.
> The first is a node-set.  The second is an RTF, for which you'd need to
> use the nodeset extension function if you want to navigate.  I think the
> first easier because you don't have to use the nodeset extension
> function.
>
> >
> > 2.  Also, you don't use the top level element name in the XPATH call, that
> > is, you used...
> >
> > <xsl:value-of select="$myRTF/ELEM1/ELEM1A"/>
> >
> > instead of...
> >
> > <xsl:value-of select="$myRTF/DOCUMENT/ELEM1/ELEM1A"/>
> >
> > which surprised me!  The second form is the correct one if you use the
> > document() function to pull in an XML file from a URI, that is, if my
> > declaration for getting the xml file had been...
> >
> >   <xsl:variable name="client" select="document('simple2.xml')"/>
> >
> > and this contained the same data as before, you would need to use
> > $myRTF/DOCUMENT/...
> >
> > Is this difference from the document() function an implementation
> > interpretation issue, a peculiarity of the spec, or a mistake?
>
> This is a little confusing.  The way I've written getMyXMLStr(), it
> returns a node-set consisting of a single node, the DOCUMENT node.  If
> you want to use your syntax, just change the getMyXMLStr() function to
> return the document by changing
>
>   NodeSet retval = new NodeSet(elemNode);
> to
>   NodeSet retval = new NodeSet(myDoc);
>
> That way, getMyXMLStr() will return a node-set consisting of a single
> node, the document root.  Then, your XPath should work fine.  The
> document() function returns the document root (see
> http://www.w3.org/TR/xslt#document) which is why it behaves the way it
> does.
>
> If you have more questions, please come back with them.  It's important
> to understand this stuff.
>
> HTH,
> Gary

Reply via email to