[jira] Created: (JXPATH-109) Namespaced attribute not selected with wildcard

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (JXPATH-109) Namespaced attribute not selected with wildcard

JIRA jira@apache.org
Namespaced attribute not selected with wildcard
-----------------------------------------------

                 Key: JXPATH-109
                 URL: https://issues.apache.org/jira/browse/JXPATH-109
             Project: Commons JXPath
          Issue Type: Bug
         Environment: ALL
            Reporter: Michele Vivoda
             Fix For: Nightly Builds


With expression:

xml/@*

On xml:

<xml xmlns:x='foo' x:pop='a'/>

selectSingleNode returns null, @x:* works fine.

Possible Fix:

In DOMAttributeIterator, line 84

if (equalStrings(testPrefix, nodePrefix)) {
                return true;
            }

should probably be changed to

if (testPrefix==null || equalStrings(testPrefix, nodePrefix)) {
                return true;
            }


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

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (JXPATH-109) Namespaced attribute not selected with wildcard

JIRA jira@apache.org

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

Michele Vivoda commented on JXPATH-109:
---------------------------------------

Making the change as suggeste breaks one test, that in my opinion is wrong.

Line 543 of XMLModelTestCase

        // attribute:: with default namespace and wildcard
        assertXPathValueIterator(
            context,
            "vendor/product/price:amount/@*",
            list("20%"));

A wildcard attribute selects all the attributes with or without a namespace,
and not as is written, attributes with default namespace.

So I believe it should be changed to :

        // attribute:: with no namespace
        assertXPathValueIterator(
            context,
            "vendor/product/price:amount/@*[namespace-uri()='']",
            list("20%"));

       // attribute::  all
        assertXPathValueIterator(
            context,
            "vendor/product/price:amount/@*",
            set("10%", "20%"));

must also add to JXPathTestCase:

protected static Set set(Object o1, Object o2) {
        Set list = new HashSet();
        list.add(o1);
        list.add(o2);
        return list;
    }

Running the test I noticed also JDOM model is affected by the same problem,
so at line 82 of JDOMAttributeIterator:

if (attr.getNamespace().equals(ns)) {
                        attributes.add(attr);
}

should become:

if (prefix==null || attr.getNamespace().equals(ns)) {
                        attributes.add(attr);
}

With this last change tests run ok.

> Namespaced attribute not selected with wildcard
> -----------------------------------------------
>
>                 Key: JXPATH-109
>                 URL: https://issues.apache.org/jira/browse/JXPATH-109
>             Project: Commons JXPath
>          Issue Type: Bug
>         Environment: ALL
>            Reporter: Michele Vivoda
>             Fix For: Nightly Builds
>
>
> With expression:
> xml/@*
> On xml:
> <xml xmlns:x='foo' x:pop='a'/>
> selectSingleNode returns null, @x:* works fine.
> Possible Fix:
> In DOMAttributeIterator, line 84
> if (equalStrings(testPrefix, nodePrefix)) {
>                 return true;
>             }
> should probably be changed to
> if (testPrefix==null || equalStrings(testPrefix, nodePrefix)) {
>                 return true;
>             }

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

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (JXPATH-109) Namespaced attribute not selected with wildcard

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/JXPATH-109?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Benson resolved JXPATH-109.
--------------------------------

       Resolution: Fixed
    Fix Version/s:     (was: Nightly Builds)
                   1.3

fixed; rev 617940

> Namespaced attribute not selected with wildcard
> -----------------------------------------------
>
>                 Key: JXPATH-109
>                 URL: https://issues.apache.org/jira/browse/JXPATH-109
>             Project: Commons JXPath
>          Issue Type: Bug
>         Environment: ALL
>            Reporter: Michele Vivoda
>             Fix For: 1.3
>
>
> With expression:
> xml/@*
> On xml:
> <xml xmlns:x='foo' x:pop='a'/>
> selectSingleNode returns null, @x:* works fine.
> Possible Fix:
> In DOMAttributeIterator, line 84
> if (equalStrings(testPrefix, nodePrefix)) {
>                 return true;
>             }
> should probably be changed to
> if (testPrefix==null || equalStrings(testPrefix, nodePrefix)) {
>                 return true;
>             }

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