jaxen
  1. jaxen
  2. JAXEN-105

Missing namespace nodes on the namespace axis

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.1
    • Component/s: dom
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Jaxen is failing this test:

      org.w3c.dom.Element root = doc.createElement("root");
      doc.appendChild(root);
      Element child = doc.createElementNS("http://www.example.org", "foo:child");
      root.appendChild(child);

      XPath xpath = new DOMXPath("//namespace::node()");
      List result = xpath.selectNodes(doc);
      assertEquals(3, result.size());

      This query on this document should find three nodes: a namespace node for the xml prefix on the root, a namespace node for the xml prefix on the child, and a namespace node for the foo prefix on the child. It only finds the first two. (I've inspected this with the debugger.) For some reason it misses the foo prefix.

      I haven't fully tracked this down yet. It might be a problem in the DOM navigator. It might be a problem in Jaxen itself.

        Activity

        Hide
        Elliotte Rusty Harold added a comment -

        I think I've figured out this bug. It's a problem in the DOM navigator. That navigator assumes that all namespace nodes are represented by Attr objects. However, this is not necessarily true for synthetically created documents. These may have namespaces but no Attr objects at all. It's basic DOM brain damage, and should not affect anything in the core or other navigators. I'm working on fixing it.

        Show
        Elliotte Rusty Harold added a comment - I think I've figured out this bug. It's a problem in the DOM navigator. That navigator assumes that all namespace nodes are represented by Attr objects. However, this is not necessarily true for synthetically created documents. These may have namespaces but no Attr objects at all. It's basic DOM brain damage, and should not affect anything in the core or other navigators. I'm working on fixing it.
        Hide
        Elliotte Rusty Harold added a comment -

        I've fixed the basic issues. The DOM navigator will now generate namespace nodes from elements and attributes' namespaces, as well as explicit xmlns Attr objects. There may still be some issues with ancestral namespaces I need to look at. I have no idea what to do with DOM trees in which the Attr objects are in active conflict with the actual namespaces. This is a real mismatch between DOM and XPath.

        Show
        Elliotte Rusty Harold added a comment - I've fixed the basic issues. The DOM navigator will now generate namespace nodes from elements and attributes' namespaces, as well as explicit xmlns Attr objects. There may still be some issues with ancestral namespaces I need to look at. I have no idea what to do with DOM trees in which the Attr objects are in active conflict with the actual namespaces. This is a real mismatch between DOM and XPath.
        Hide
        Elliotte Rusty Harold added a comment -

        What Jaxen is currently doing is ignoring the additional, contradictory namespace declarations. I think I'm going to write tests for this and declare this to be the expected behavior.

        I'm furthermore going to rule that the intrinsic namespace of an Element or Attr wins over the contradictory namespace declared by an xmlns or xmlns:pre attribute.

        There's no good solution here (Blame DOM for that); but it's an edge case; and this approach feels marginally less surprising.

        Show
        Elliotte Rusty Harold added a comment - What Jaxen is currently doing is ignoring the additional, contradictory namespace declarations. I think I'm going to write tests for this and declare this to be the expected behavior. I'm furthermore going to rule that the intrinsic namespace of an Element or Attr wins over the contradictory namespace declared by an xmlns or xmlns:pre attribute. There's no good solution here (Blame DOM for that); but it's an edge case; and this approach feels marginally less surprising.
        Hide
        Elliotte Rusty Harold added a comment -

        I think this is now resolved and document as best as possible. Honestly DOM is just truly brain damaged here.

        Show
        Elliotte Rusty Harold added a comment - I think this is now resolved and document as best as possible. Honestly DOM is just truly brain damaged here.

          People

          • Assignee:
            Elliotte Rusty Harold
            Reporter:
            Elliotte Rusty Harold
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: