Title: Message
John et all,
 
I have made some minor changes to DTMDocument that I believe cause it to function consistently with the XPath specification. I have tested these on my system and they function as I believe they should. The attached file contains the modified functions. In short there was a very minor change to getNodeValue() to not return "#element" for element nodes, getStringValue() was changed to return the text content of element nodes, and getNodeData() is a new function used by getStringValue() to get the node text content (this is modeled after the similarly named function in DOM2DTM). Actually all of this is modeled after DOM2DTM, since I assume that DOM2DTM works properly in this regard.
 
If this code stands up to scrutiny, could someone commit it to CVS.
 
Hopefully tomorrow I will get back to looking at my proposed enhancements to the SQL extension. At least now I have a better understanding of how DTM works as a result of this little detour.
 
Thank You,
Art
 
-----Original Message-----
From: John Gentilin [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 26, 2002 2:03 PM
To: [EMAIL PROTECTED]
Subject: Re: SQL and XPath Problem?

Art,

The behavior you describe is the behavior that is programmed into
the SQL extension. As far as I know, I am supplying the correct values
as per the spec, if this is not true we can change it.

With you desc2 element, you are asking for the string value of an Element
Node and not the child text node. Element nodes have a default value of
#element and text nodes have a default name of #text.
To make this work, you need to apply the text() axis function to pass the
value of the text element to the String function i.e.

<desc2><xsl:value-of select="string($queryresult/sql/row-set/row/col[1]/text())"/></desc2>

Regards
John G

[EMAIL PROTECTED] wrote:

 

Before I enter it into Bugzilla as a bug, I figure that I will run this by the Xalan group. I have been trying to figure this out for a while - with no success.

I have been doing some work with the SQL extension. I have encountered what appears to be a bug. When I attempt to use the results of an SQL query in some XPath expressions it fails. It looks like it may be things that involve conversion of the result to a string. For example the following stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0"
                xmlns:sql="org.apache.xalan.lib.sql.XConnection"
                extension-element-prefixes="sql">

  <xsl:param name="query" select="'SELECT short_description FROM bkparama WHERE groupid = 25 and ordinal = 1'"/>

<xsl:template match="/">
<root>
    <!-- 1. Make the connection -->
    <xsl:variable name="connection2"
                  select="sql:new('com.sybase.jdbc2.jdbc.SybDriver',
                                'jdbc:sybase:Tds:dev1:1234/teller', 'user', 'password')"/>
        <xsl:variable name="queryresult" select="sql:query($connection2, $query)"/>

        <desc1><xsl:value-of select="$queryresult/sql/row-set/row/col[1]"/></desc1>
        <desc2><xsl:value-of select="string($queryresult/sql/row-set/row/col[1])"/></desc2>
        <desc3><xsl:value-of select="$queryresult/sql/row-set/row/col[1]"/></desc3>

        <!-- 3. Close the connection -->
        <xsl:value-of select="sql:close($connection2)"/>
</root>
</xsl:template>
</xsl:stylesheet>

Produces the following output:

<?xml version="1.0" encoding="UTF-8"?>
<root><desc1>Curr Proc Date</desc1><desc2>#element</desc2><desc3>Curr Proc Date</desc3></root>

As you can see, the output appears to be correct except when the XPath string() function is invoked on the column. In this case it is giving the type of the node instead of the content of the node.

I have backed into this so far as to see that in FunctionDef1Arg.getArg0AsString() it is getting a NodeSet as the argument. This nodeset when converted to a string gives "#element". It appears to be because nodelist().item(0) of this nodeset gives "#element" for getNode Value() (getNodeName() = "col"). If this is DOM, I would expect an element node to have NULL for the value. Pursuing this further, I can getFirstChild() on this node and for this I get getNodeName()="#text" and getNodeValue()="The text I want".

The next stop on my journey through the code was in DTMDocument.getStringValue() because this is invoked by XNodeSet.getStringFromNode(). The DTMDocument.getStringValue() function obtains an object from m_ObjectArray. This object turns out to be the java.lang.String "#element". Unfortunately at this point I am a bit stuck. Here it appears to get into some DTM stuff that I have not figured out yet. I am hoping that someone can point out some glaring problem with what I am doing that I am completely missing, or point me in the right direction anyway.

Alternatively if someone can confirm that this is a bug and not just a misunderstanding on my part, I will enter it into Bugzilla - and/or try to resolve it myself and submit a patch.

Thank You,
Art

--
--------------------------------------
John Gentilin
Eye Catching Solutions Inc.
18314 Carlwyn Drive
Castro Valley CA 94546

    Contact Info
[EMAIL PROTECTED]
Ca Office 1-510-881-4821
NJ Office 1-732-422-4917
 

Attachment: DTMDocumentModifiedFunctions.java
Description: Binary data

Reply via email to