jaxb
  1. jaxb
  2. JAXB-209

Schema-driven XmlAdapter using xjc:javaType

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1.12
    • Fix Version/s: not determined
    • Component/s: xjc
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      209

      Description

      In situations where modifying schema-derived classes is not an option, it would
      be very nice to be able to use xjc:javaType to map schema types to more natural
      java types. For instance, being able to map a schema type to a HashMap might
      be a likely requirement for those using model driven design/implementation.
      AFAICS, this is not possible today. Therefore, one must manually edit the
      generated code.

        Activity

        Hide
        uprooter added a comment -

        bump.

        Show
        uprooter added a comment - bump.
        Hide
        dma_k added a comment -

        rtiernay, can you please provide a more verbose example? Do you need to map a
        complete type, like shown here:
        http://stackoverflow.com/questions/1881712/is-it-possible-to-use-jaxb-to-map-from-schema-to-a-java-util-map
        ?

        Show
        dma_k added a comment - rtiernay, can you please provide a more verbose example? Do you need to map a complete type, like shown here: http://stackoverflow.com/questions/1881712/is-it-possible-to-use-jaxb-to-map-from-schema-to-a-java-util-map ?
        Hide
        royalpeasantry added a comment -

        That is the functionality I am looking for.

        Currently it is only possible to translate from a Simple XML type to any Java
        Type. It should also be possible to use an XMLAdaptor to translate from a
        Complex XML type to any JavaType using <xjc:javaType name="<JavaType>"
        adaptor="<XMLAdaptor>">.

        Unless I am mistaken everything works perfectly if you manually code up the
        class using @XMLJavaTypeAdaptor, but it cannot be schema-generated because
        JavaType cannot be bound to a Complex Type. If the schema would allow JavaType
        to be bound to both complex and simple types I suspect it would work perfectly.

        This defect is related as well.. Without it you cannot use generics in the
        'name' attribute of 'JavaType'. (<xjc:javaType name="java.util.Map<String,
        Integer>" adaptor=...> for example)
        https://jaxb.dev.java.net/issues/show_bug.cgi?id=737

        Show
        royalpeasantry added a comment - That is the functionality I am looking for. Currently it is only possible to translate from a Simple XML type to any Java Type. It should also be possible to use an XMLAdaptor to translate from a Complex XML type to any JavaType using <xjc:javaType name="<JavaType>" adaptor="<XMLAdaptor>">. Unless I am mistaken everything works perfectly if you manually code up the class using @XMLJavaTypeAdaptor, but it cannot be schema-generated because JavaType cannot be bound to a Complex Type. If the schema would allow JavaType to be bound to both complex and simple types I suspect it would work perfectly. This defect is related as well.. Without it you cannot use generics in the 'name' attribute of 'JavaType'. (<xjc:javaType name="java.util.Map<String, Integer>" adaptor=...> for example) https://jaxb.dev.java.net/issues/show_bug.cgi?id=737

          People

          • Assignee:
            jaxb-issues
            Reporter:
            rtiernay
          • Votes:
            26 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated: