Bug #2052

Metacat does not handle attribute XPATH queries correctly

Added by Chris Jones over 17 years ago. Updated over 17 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


When metacat is queried and one of the query parameters is a an XML attribute
expressed in XPATH, the resultant squery that is created doesn't create the
correct XPATH for the attribute. The final '/' before the attribute is
ommitted. This should be a simple fix in

Also, when only an attribute is used as a query parameter, an exception is
thrown in newPathExpressionWithOutAttribute in

An example:
(produces returned documents)
(produces the exception and no documents)


#1 Updated by Chris Jones over 17 years ago

Added the trailing '/' in that was ommitted when XPATH queries
included attributes

#2 Updated by Chris Jones over 17 years ago

On closer inspection, there are two remaining issues here:

1) path queries with no element content (only attribute) throw an exception and,

2) path queries with element content like './' don't throw an exception, but end
up creating a sub-select in the xml_nodes table that never returns any rows:

(SELECT nodeid FROM xml_index WHERE path LIKE '.')

The SQL code will need to be modified to handle the cases.

#3 Updated by Chris Jones over 17 years ago

In, when searching for attributes in the XPATH
expression, an 'index out of bounds'
exception was thrown when only an attribute was included in the path string.

This fix changes the pathexpr.indexOf comparison to 0 rather than 1, since
the index starts at 0.

#4 Updated by Chris Jones over 17 years ago

When a path expression includes element content and attribute content, then
the SQL generated needs to search for attribute nodetypes with parent
nodenames equal to the path expression element content. However, when
only searching for attribute content (such as just packageId), then
the parent sub-select needs to be omitted. This patch omits the parent
sub-select when the pathexpr starts with '
', './', or '../'.

#5 Updated by Chris Jones over 17 years ago

Changes to the Query subsystem fix bugs that prevented attributes from being
expressed solely in the xpath query statement and the returnfield values.
For instance, a query URL may now include search strings like
'@packageId=sbclter%25' and return strings like 'returnfield=@packageId'.
Previously, the attribute had to be appended to an element:
'/eml/@packageId=sbclter%25'. These fixes change,, and

#6 Updated by Redmine Admin over 9 years ago

Original Bugzilla ID was 2052

Also available in: Atom PDF