Bug #2052
closedMetacat does not handle attribute XPATH queries correctly
0%
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)
Updated by Chris Jones over 19 years ago
Added the trailing '/' in DBQuery.java that was ommitted when XPATH queries
included attributes
Updated by Chris Jones over 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.
Updated by Chris Jones over 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.
Updated by Chris Jones over 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 '../
'.
Updated by Chris Jones over 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.