Cocoon
  1. Cocoon
  2. COCOON-1893

XML-Binding: Problem creating a new element

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1.9
    • Fix Version/s: None
    • Component/s: Blocks: Forms
    • Labels:
      None
    • Other Info:
      Patch available

      Description

      Creating a new element with a namespace fails, if no parent element of the new element already defines the namespace. In this case the operation org.apache.cocoon.util.jxpath.DOMFactory#getNamespaceURI(Element element, String prefix) returns null which result in the following exception:
      org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.

      Instead of just relying on the parents to define the namespace the element should define the namespace itself if no parent provides the definition. To do so we need to map the prefix of the element to the namespace the prefix refers to. This can be done using the namespaces the JXPathContext knows. To use the JXPathContext we need to pass the context to the operation that does the mapping.

      This is done by the attached DOMFactory.

      1. DOMFactory_PATCH.java
        5 kB
        Fabian Linz
      2. diff.txt
        1 kB
        Fabian Linz

        Activity

        Hide
        Fabian Linz added a comment -
        Changed DOMFactory based on Cocoon 2.1.9 release
        Show
        Fabian Linz added a comment - Changed DOMFactory based on Cocoon 2.1.9 release
        Hide
        Fabian Linz added a comment -
        Diff for changes
        Show
        Fabian Linz added a comment - Diff for changes
        Hide
        Wadim Kruse added a comment -
        The patch solves the described error above. Thanks a lot!
        Additionally I had to apply a patch from: http://issues.apache.org/jira/browse/COCOON-1686 in order to solve a problem with unknown namespaces in the result document (xmlns:xi="<<unknown namespace>>").
        Show
        Wadim Kruse added a comment - The patch solves the described error above. Thanks a lot! Additionally I had to apply a patch from: http://issues.apache.org/jira/browse/COCOON-1686 in order to solve a problem with unknown namespaces in the result document (xmlns:xi="<<unknown namespace>>").

          People

          • Assignee:
            Unassigned
            Reporter:
            Fabian Linz
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development