Project

General

Profile

Actions

Bug #2052

closed

Metacat does not handle attribute XPATH queries correctly

Added by Chris Jones about 19 years ago. Updated about 19 years ago.

Status:
Resolved
Priority:
Immediate
Assignee:
Category:
metacat
Target version:
Start date:
03/23/2005
Due date:
% Done:

0%

Estimated time:
Bugzilla-Id:
2052

Description

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 DBQuery.java.

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

An example:

http://metacat.nceas.ucsb.edu/knb/servlet/metacat?action=query&qformat=xml&/eml/@packageId=%25
(produces returned documents)

http://metacat.nceas.ucsb.edu/knb/servlet/metacat?action=query&qformat=xml&@packageId=%25
(produces the exception and no documents)

Actions #1

Updated by Chris Jones about 19 years ago

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

Actions #2

Updated by Chris Jones about 19 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.

Actions #3

Updated by Chris Jones about 19 years ago

In QuerySpecification.java, 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.

Actions #4

Updated by Chris Jones about 19 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 '../'.

Actions #5

Updated by Chris Jones about 19 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 DBQuery.java,
QuerySpecification.java, and QueryTerm.java.

Actions #6

Updated by Redmine Admin about 11 years ago

Original Bugzilla ID was 2052

Actions

Also available in: Atom PDF