castor
  1. castor
  2. CASTOR-2209

unmarshal() method in subtype should return subtype.

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.2.1
    • Fix Version/s: 1.2
    • Component/s: XML
    • Labels:
      None
    • Number of attachments :
      2

      Description

      Thread: http://www.nabble.com/unmarshal%28%29-method-for-named-element-with-%27type%27-attribute-tf4681201.html

      Actually, I just learned myself that what I have said is valid for Java
      1.4 and below only. With java 5.0 and baove, this will be possible.

      As such, can you please create a new Jira issue, asking us to support this.

      Regards
      Werner

      <?xml version="1.0" encoding="UTF-8"?>
      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0.0">
              <xsd:element name="AKConfig" type="AKConfigType">
                      <xsd:annotation>
                              <xsd:documentation>AK Config</xsd:documentation>
                      </xsd:annotation>
              </xsd:element>
              <xsd:complexType name="AKConfigType">
                      <xsd:sequence>
                              <xsd:element name="handler" type="xsd:string" />
                              <xsd:element name="timeout" type="xsd:int" />
                              <xsd:element name="allowMultiplePartsPerCnxn" type="xsd:boolean" default="false" />
                              <xsd:element name="CategoryList" type="CategoryListType" />
                      </xsd:sequence>
              </xsd:complexType>
              <xsd:complexType name="CategoryListType">
                      <xsd:sequence>
                              <xsd:element name="CnxnCategory" type="CategoryType" minOccurs="0" maxOccurs="unbounded" />
                      </xsd:sequence>
              </xsd:complexType>
              <xsd:complexType name="CategoryType">
                      <xsd:attribute name="value" type="xsd:string" use="required" />
                      <xsd:attribute name="MaxConnectionsAllowed" type="xsd:int" use="optional" default="1" />
              </xsd:complexType>
      </xsd:schema>
      

      In the generated AKConfig.java, the unmarshal() method is:

      public static com.ak.castor.AKConfigType unmarshal(
                  final java.io.Reader reader)
          throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
              return (com.ak.castor.AKConfigType) Unmarshaller.unmarshal(com.ak.castor.AKConfig.class, reader);
          }
      

      Why does this method return AKConfigType, and not AKConfig?

      1. patch.c2209.20071029.txt
        1.0 kB
        Werner Guttmann
      2. patch.cstaticunmarshal.20071025.txt
        2 kB
        Werner Guttmann

        Activity

        Hide
        Werner Guttmann added a comment -

        I still need to update the release notes to make this change (more) explicit, as clearly it changes an outbound contract (again).

        Show
        Werner Guttmann added a comment - I still need to update the release notes to make this change (more) explicit, as clearly it changes an outbound contract (again).
        Hide
        Werner Guttmann added a comment -

        Aslam, have you been able to have a look at this patch ?

        Show
        Werner Guttmann added a comment - Aslam, have you been able to have a look at this patch ?
        Hide
        Aslam Karachiwala added a comment -

        Looks good. Will attach the the XML/XSD example.

        Show
        Aslam Karachiwala added a comment - Looks good. Will attach the the XML/XSD example.
        Hide
        Aslam Karachiwala added a comment -

        XML example for the schema above:

        <?xml version="1.0" encoding="UTF-8"?>
        <AKConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="AKConfig.xsd">
          <handler>handler</handler>
          <timeout>0</timeout>
          <allowMultiplePartsPerCnxn>false</allowMultiplePartsPerCnxn>
          <CategoryList>
            <CnxnCategory MaxConnectionsAllowed="1" value=""/>
          </CategoryList>
        </AKConfig>
        
        Show
        Aslam Karachiwala added a comment - XML example for the schema above: <?xml version= "1.0" encoding= "UTF-8" ?> <AKConfig xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "AKConfig.xsd" > <handler> handler </handler> <timeout> 0 </timeout> <allowMultiplePartsPerCnxn> false </allowMultiplePartsPerCnxn> <CategoryList> <CnxnCategory MaxConnectionsAllowed= "1" value=""/> </CategoryList> </AKConfig>
        Hide
        Werner Guttmann added a comment -

        Thanks. Should be able to commit this patch soon-ish.

        Show
        Werner Guttmann added a comment - Thanks. Should be able to commit this patch soon-ish.

          People

          • Assignee:
            Werner Guttmann
            Reporter:
            Aslam Karachiwala
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: