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
hello.xml
Description: Binary data
|