jaxb
  1. jaxb
  2. JAXB-818

Generate @XmlNs annotations on package-info.java

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: xjc
    • Labels:
      None

      Description

      I'm using xjc to generate a JAXB model from an XSD schema with multiple imported namespaces. I would like to override the default namespace prefixes (ns1, ns2, ...) used by the JAXB marshaller by sensible defaults.

      This can be done by setting an xmlns property in the @XmlSchema annotation at package level in package-info.java.

      However, this file is generated by xjc by default, without any prefix definitions.

      Currently, the only way of overriding this behaviour seems to be:

      • Manually create package-info.java.
      • Run xjc with the -npa option to avoid generating package-info.java.

      It would be convenient if the generated package-info.java contained @XmlNs annotations using the prefixes defined in the schema to be compiled, if present. In addition, there should be a mechanism to override the defaults by a suitable xjb customization.

        Activity

        Hide
        ccu54 added a comment -

        I got the same issue : I need to generate a package-info.java containing a custom XmlNs prefix, eg. :

        @javax.xml.bind.annotation.XmlSchema(
                (...),
                xmlns = {@javax.xml.bind.annotation.XmlNs(prefix = "foo", namespaceURI = "http://mysite.com/xml/foo-v1.0.xsd")},
                (...))
        
        Show
        ccu54 added a comment - I got the same issue : I need to generate a package-info.java containing a custom XmlNs prefix, eg. : @javax.xml.bind.annotation.XmlSchema( (...), xmlns = {@javax.xml.bind.annotation.XmlNs(prefix = "foo" , namespaceURI = "http: //mysite.com/xml/foo-v1.0.xsd" )}, (...))
        Hide
        silverhawk87 added a comment -

        I am having the same issue; this would be a great feature to have...

        Show
        silverhawk87 added a comment - I am having the same issue; this would be a great feature to have...
        Hide
        puce added a comment -

        +1 for taking defaults from the XSD and generate the @XmlNs annotations
        +1 for making this customizable with xjb customization

        Show
        puce added a comment - +1 for taking defaults from the XSD and generate the @XmlNs annotations +1 for making this customizable with xjb customization

          People

          • Assignee:
            Martin Grebac
            Reporter:
            Harald Wellmann
          • Votes:
            12 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated: