Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-489

Cursor getAllNamespaces not returning default namespace

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Version 2.6
    • Version 3.0.0
    • Cursor
    • None

    Description

      the Cursor getAllNamespaces API is not returning the default namespace that is in scope for an element.
      In org.apache.xmlbeans.impl.store.Locale class, line 2316 is this code, which intentionally omits the default namespace from the mapping.

      // Here I check to see if there is a default namespace
      // mapping which is not empty on a non root container which
      // is in a namespace. This this case, I do not want to add
      // this mapping because it could not be persisted out this
      // way.

      if (prefix.length() == 0 && uri.length() > 0 &&
      cName != null &&
      cName.getNamespaceURI().length() > 0)

      { continue; }

      from SVN history, it was added in r110897
      http://svn.apache.org/viewvc/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Locale.java?revision=110897&view=markup&pathrev=1386853

      As an example, given
      <a xmln=""><b xmlns="namespaceb"><c xmlns:c1="namespacec"/></b></a>

      Using Cursor API, navigate to element c then call getAllNamespaces, it returns
      "",""
      c1,"namespacec"
      which is incorrect, since the default namespace was redeclared in element b, the correct return should be
      "","namespaceb"
      c1,"namespacec"

      The proposed fix is to comment out that "if" block. I have tested that fix to pass checkintest.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            jerrysy Jerry Sy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment