[ 
https://issues.apache.org/jira/browse/JXPATH-61?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12497872
 ] 

Richard Unger commented on JXPATH-61:
-------------------------------------

HI!

Fair enough to close this issue. (When I originally reported it, I never 
dreamed it would cause such a discussion!)

However, keep in mind that if JXPath ever aims to support XPath 2.0 (now a W3c 
Recommendation) this issue will have to be addressed.

The XSLT 2.0 standard says (section 5.2):

"The attribute [xsl:]xpath-default-namespace  (see 3.5 Standard Attributes) may 
be used on an element in the stylesheet  to define the namespace that will be 
used for an unprefixed element name or type name within an XPath expression, 
and in certain other contexts listed below."

and XPath 2.0 says (Section 2.1, Expression Context):
"The individual components of the static context are summarized below. A 
default initial value for each component may be specified by the host language. 
The scope of each component is specified in C.1 Static Context Components.
 [...]
    *[Definition: Default element/type namespace. This is a namespace URI or 
"none". The namespace URI, if present, is used for any unprefixed QName 
appearing in a position where an element or type name is expected.] The URI 
value is whitespace normalized according to the rules for the xs:anyURI type in 
[XML Schema].

So for XPath 2.0, this exact feature is required.

> [jxpath] Default Namespace not handled correctly
> ------------------------------------------------
>
>                 Key: JXPATH-61
>                 URL: https://issues.apache.org/jira/browse/JXPATH-61
>             Project: Commons JXPath
>          Issue Type: Improvement
>    Affects Versions: 1.2 Final
>         Environment: Operating System: All
> Platform: All
>            Reporter: Richard Unger
>            Priority: Minor
>
> JXPath 1.2 does not handle the default namespace correctly. There is no way to
> set the default namespace on a context, so xpath expressions with unprefixed
> node-selections do not match the default namespace.
> Eg:
> <?xml version="1.0" encoding="iso-8859-1"?>
> <test xmlns="http://test";>
>   <child-element />
> </test>
> This is valid xml, with default namespace 'http://test'
> If the following xpath expression is used: '/test/childelement', it will not
> match the child-element element in this xml file.
> There appears to be no way to use the function 
> JXPathContext.registerNamespace()
> to associate a default namespace with the context.
> The programmer is forced to introduce a namespace prefix for JXPath, the xpath
> expression 'foo:test/foo:child-element' will correctly match the element if 
> JXPathContext.registerNamespace("foo","http://test";) is called first.
> This is, IMHO, a bug.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to