jaxb
  1. jaxb
  2. JAXB-379

Generated namespace prefixes different to NamespacePrefixMapper for identical prefixes with different URIs

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 2.1.3
    • Fix Version/s: not determined
    • Component/s: runtime
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      379

      Description

      I need to produce the following XML document which I believe is valid XML
      (according to http://www.w3.org/TR/REC-xml-names/#defaulting):

      -------------------------------------------------------------------------------------------------------------
      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <BroadsoftDocument protocol="OCI" xmlns="C">
      <sessionId xmlns="">12345</sessionId>
      <command xsi:type="AuthenticationRequest"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="">
      <userId>userId</userId>
      </command>
      </BroadsoftDocument>
      -------------------------------------------------------------------------------------------------------------

      When I try to create this document using JAXB 2 or jdk1.6, I get the following:

      -------------------------------------------------------------------------------------------------------------

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <ns2:BroadsoftDocument protocol="OCI" xmlns:ns2="C">
      <sessionId>12345</sessionId>
      <command xsi:type="AuthenticationRequest"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <userId>userId</userId>
      </command>
      </ns2:BroadsoftDocument>

      -------------------------------------------------------------------------------------------------------------

      I understand that the above XML is also valid, however, the server I am working
      with does not allow for "ns2" because it looks for "<BroadsoftDocument>" in
      order to detect an XML document (and I cannot change server-side implementation)

      In JAXB 1, the generated XML was correctly giving me the first message. But
      after upgrading to JAXB 2 (to solve other bugs), this problem has come up.
      I've looked in the source code, and it seems the JAXB implementation doesn't
      like having same prefixes for different namespace URIs as specified by the
      NamespacePrefixMapper.

      Specifically, I feel that if the NamespacePrefixMapper returns 2 identical
      prefixes for different URIs, the implementation should try its best to honor
      this mapping, particularly for inner namespace scoping. It should only create
      its own prefixes (ns2, etc) if something incorrect is happening...

        Activity

        rico_kim created issue -
        kenaiadmin made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 379 28464
        Martin Grebac made changes -
        Assignee jaxb-issues [ jaxb-issues ] Martin Grebac [ snajper ]
        Martin Grebac made changes -
        Priority Major [ 3 ] Critical [ 2 ]

          People

          • Assignee:
            Martin Grebac
            Reporter:
            rico_kim
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: