Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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 :
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
| 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 ] |
Verified that with 1.2.2 the generated code includes the attribute:
public class ElementType
{
private String string;
private String name;
/**
*/
public String getString() { return string; }
/**
*/
public void setString(String string) { this.string = string; }
/**
*/
public String getName() { return name; }
/**
*/
public void setName(String name) { this.name = name; }
}