JiBX
  1. JiBX
  2. JIBX-354

Leaf elements with attribute

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JiBX 1.2.1
    • Fix Version/s: JiBX 1.2.2
    • Component/s: CodeGen
    • Labels:
      None
    • Environment:
      java version "1.6.0_12"
      Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
      Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode)
    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      Hi

      JiBX fails on generating leaf elements with an attribute correctly. I included a test project to demonstrate that.

      In short, an XSD defining a simpleContent with an attribute extension does not privide access to the attribute.

      <?xml version="1.0" encoding="UTF-8"?>
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="Root">
      <xs:complexType>
      <xs:sequence>
      <xs:element name="element" type="elementType" maxOccurs="unbounded"/>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      <xs:complexType name="elementType">
      <xs:simpleContent>
      <xs:extension base="xs:string">
      <xs:attribute name="name" use="required"/>
      </xs:extension>
      </xs:simpleContent>
      </xs:complexType>
      </xs:schema>

      Only the element content is accessible by the generated code:

      /**

      • Schema fragment(s) for this class:
      • <pre>
      • <xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema" name="elementType">
      • <xs:simpleContent>
      • <xs:extension base="xs:string">
      • <xs:attribute use="required" name="name"/>
      • </xs:extension>
      • </xs:simpleContent>
      • </xs:complexType>
      • </pre>
        */
        public class ElementType
        {
        private String string;
        public String getString() {return string;}

        public void setString(String string)

        {this.string = string;}

        }

      Would be nice to be able to define attributed leaf elements...

      Cheers
      Daniel Frey

        Activity

        Hide
        Dennis Sosnoski added a comment -

        Verified that with 1.2.2 the generated code includes the attribute:

        public class ElementType
        {
        private String string;
        private String name;

        /**

        • Get the extension value.
        • @return value
          */
          public String getString() { return string; }

        /**

        • Set the extension value.
        • @param string
          */
          public void setString(String string) { this.string = string; }

        /**

        • Get the 'name' attribute value.
        • @return value
          */
          public String getName() { return name; }

        /**

        • Set the 'name' attribute value.
        • @param name
          */
          public void setName(String name) { this.name = name; }

          }

        Show
        Dennis Sosnoski added a comment - Verified that with 1.2.2 the generated code includes the attribute: public class ElementType { private String string; private String name; /** Get the extension value. @return value */ public String getString() { return string; } /** Set the extension value. @param string */ public void setString(String string) { this.string = string; } /** Get the 'name' attribute value. @return value */ public String getName() { return name; } /** Set the 'name' attribute value. @param name */ public void setName(String name) { this.name = name; } }
        Dennis Sosnoski made changes -
        Field Original Value New Value
        Resolution Fixed [ 1 ]
        Assignee Dennis Sosnoski [ dsosnoski ]
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s JiBX 1.2.2 [ 15120 ]

          People

          • Assignee:
            Dennis Sosnoski
            Reporter:
            Daniel Frey
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: