logo       

Bug handling xpath expressions in Chiba 0.9.2!!!: msg#00027

Subject: Bug handling xpath expressions in Chiba 0.9.2!!!
Joern:

I just discovered a nasty bug in the 0.9.2 release, and given the examples 
you are using, expect that it is still there in the current version that you 
are working on (0.9.3).

The problem manifests itself if you use XPath selectors that do a comparison 
based on an attribute.  For example:

If you do something like this:

        <xforms:output xforms:ref="/root/name[@id='name1']"/>

Then you will die with a  null pointer exception inside the getDataItem() 
method of org.chiba.xml.xforms.Instance.java.

The bug is in the getDataItem(), since it takes a very simplistic approach to 
figuring out whether you are accessing an attribute (it looks for an embedded 
'@' character in the locationPath).  The problem is that this causes the 
wrong logic path to be selected when the ref is of the form above and thus a 
null value to be assigned to the node variable.

I put in place a quick hack to fix this issue for my client application by 
changing the line inside getDataItem():
                
                if l(ocationPath.indexOf('@')> -1) {

to be the following two lines:

        int lpIndex = locationPath.indexOf('@');
                        
        if (lpIndex > -1 && !( lpIndex > 0 && locationPath.charAt( lpIndex - 1 
) == 
'[' ) ) {

This just checks to see if the '@' character is immediately preceeded by an 
"[", which handles all the stuff that I am using.  However, this only assumes 
a single "@" character and that the "[" always precedes the "@"....which 
given the complex nature of xpath selector syntax, is not necessarily always 
true in general.

A longer term solution should probably do much more "intelligent" analysis of 
the locationPath string to determine whether the path refers just to a simple 
attribute....or whether it has a complex xpath selector built into it or not. 
 

Unfortunately, I'm too busy with my client project to flesh out a proper 
solution, so have to leave that as an exercise for you. <grins>

I've also attached a slightly modified copy of the hello.xml form which will 
cause this bug to appear when you try to run it with the base Chiba 0.9.2 
release.  

Please note that Chiba 0.8 did NOT have this problem, and ref fields with 
embedded selectors as shown at the start of this email worked just fine!  
(You may have to change the xml:base attribute to get it to run with your 
system!).

Thanks!

Andrzej Jan Taramina
Chaeron Corporation: Enterprise System Solutions
http://www.chaeron.com

The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any other MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.

   ---- File information -----------
     File:  hello.xml
     Date:  14 Oct 2003, 13:12
     Size:  1526 bytes.
     Type:  Unknown

Attachment: hello.xml
Description: Binary data

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe