do xml automatically or manually in java?

E

Elhanan

hi..

my application should process incoming xml values, and i want to wrap
it up in wrapper classes.
questions is should i use i jaxp for this thing or create the classes
manually piece by piece for optimized coding (note said xml should be
saved in database so i thought i might hibernate for this).

here is the xml's xsd:

<?xml version="1.0" encoding="UTF-8"?>
<!--W3C Schema generated by XMLSPY v2004 rel. 3 U
(http://www.xmlspy.com)-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="AggregateValue">
<xs:complexType>
<xs:attribute name="Value1" type="xs:string" use="required"/>
<xs:attribute name="Value2" type="xs:string" use="required"/>
<xs:attribute name="Unit" type="xs:string" use="required"/>
<xs:attribute name="UnitName" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="AttributeValue">
<xs:complexType>
<xs:choice minOccurs="0">
<xs:element ref="BoolValue"/>
<xs:element ref="DateValue"/>
<xs:element ref="DualValue"/>
<xs:element ref="AggregateValue"/>
<xs:element ref="SingleValue"/>
<xs:element ref="PeriodValue"/>
<xs:element ref="StringValue"/>
<xs:element ref="TimeValue"/>
<xs:element ref="DBRefValue"/>
<xs:element ref="CORefValue"/>
<xs:element ref="ListValue"/>
<xs:element ref="SetValue"/>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="Benefit">
<xs:complexType>
<xs:sequence>
<xs:element ref="CaseAttribute" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:string" use="required"/>
<xs:attribute name="TypeId" type="xs:string" use="required"/>
<xs:attribute name="TypeIdName" type="xs:string"/>
<xs:attribute name="Identifies" type="xs:string"/>
<xs:attribute name="Locale" type="xs:string"/>
<xs:attribute name="AddedByPOSRequest" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="BoolValue">
<xs:complexType>
<xs:attribute name="Value" use="required">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="CORefValue">
<xs:complexType>
<xs:attribute name="Value" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="Case">
<xs:complexType>
<xs:sequence>
<xs:element ref="Source" maxOccurs="unbounded"/>
<xs:element ref="PosRequest" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="CaseObject"/>
<xs:element ref="Benefit"/>
<xs:element ref="Payment"/>
<xs:element ref="EventPayment"/>
<xs:element ref="CaseObjectRelation"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="Id" type="xs:string" use="required"/>
<xs:attribute name="CSP" type="xs:string" use="required"/>
<xs:attribute name="NumberOfSourceChanges" type="xs:string"/>
<xs:attribute name="CaseMode" use="required">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="POS"/>
<xs:enumeration value="HeadOffice"/>
<xs:enumeration value="FORM"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Locale" type="xs:string" use="required"/>
<xs:attribute name="Complete">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="Yes"/>
<xs:enumeration value="No"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="CaseAttribute">
<xs:complexType>
<xs:sequence>
<xs:element ref="CaseAttributeValue" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="TypeId" type="xs:string" use="required"/>
<xs:attribute name="TypeIdName" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="CaseAttributeValue">
<xs:complexType>
<xs:choice minOccurs="0">
<xs:element ref="BoolValue"/>
<xs:element ref="DateValue"/>
<xs:element ref="DualValue"/>
<xs:element ref="AggregateValue"/>
<xs:element ref="SingleValue"/>
<xs:element ref="PeriodValue"/>
<xs:element ref="StringValue"/>
<xs:element ref="TimeValue"/>
<xs:element ref="DBRefValue"/>
<xs:element ref="CORefValue"/>
<xs:element ref="ListValue"/>
<xs:element ref="SetValue"/>
</xs:choice>
<xs:attribute name="Source" type="xs:string"/>
<xs:attribute name="TemporalDescription" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="CaseObject">
<xs:complexType>
<xs:sequence>
<xs:element ref="CaseAttribute" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:string" use="required"/>
<xs:attribute name="TypeId" type="xs:string" use="required"/>
<xs:attribute name="TypeIdName" type="xs:string"/>
<xs:attribute name="Identifies" type="xs:string"/>
<xs:attribute name="Locale" type="xs:string"/>
<xs:attribute name="AddedByPOSRequest" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="CaseObjectRelation">
<xs:complexType>
<xs:attribute name="From" type="xs:string" use="required"/>
<xs:attribute name="To" type="xs:string" use="required"/>
<xs:attribute name="TypeId" type="xs:string" use="required"/>
<xs:attribute name="TypeIdName" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="CaseResult">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="CaseResultAttribute" minOccurs="0"/>
<xs:element ref="MissingInfo" minOccurs="0"/>
<xs:element ref="Explanation" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:string" use="required"/>
<xs:attribute name="ResultTypeId" type="xs:string" use="required"/>
<xs:attribute name="ResultTypeIdName" type="xs:string"/>
<xs:attribute name="ResultLevelId" type="xs:string" use="required"/>
<xs:attribute name="ResultLevelIdName" type="xs:string"/>
<xs:attribute name="SuppressedById" type="xs:string"/>
<xs:attribute name="SuppressedByType">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="Consolidated"/>
<xs:enumeration value="Subsumed"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="CaseResultAttribute">
<xs:complexType>
<xs:sequence>
<xs:element ref="AttributeValue"/>
</xs:sequence>
<xs:attribute name="ResultAttributeTypeId" type="xs:string"
use="required"/>
<xs:attribute name="ResultAttributeTypeIdName" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="CaseRisk">
<xs:complexType>
<xs:sequence>
<xs:element ref="CaseResult" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:string" use="required"/>
<xs:attribute name="RiskTypeId" type="xs:string" use="required"/>
<xs:attribute name="RiskTypeIdName" type="xs:string"/>
<xs:attribute name="ResultLevelId" type="xs:string" use="required"/>
<xs:attribute name="ResultLevelIdName" type="xs:string"/>
<xs:attribute name="RiskText" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="DBRefValue">
<xs:complexType>
<xs:attribute name="Name" type="xs:string"/>
<xs:attribute name="Id" type="xs:string"/>
<xs:attribute name="Key" type="xs:string"/>
<xs:attribute name="Locale" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="DateFrom">
<xs:complexType>
<xs:sequence>
<xs:element ref="DateValue"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="DateTo">
<xs:complexType>
<xs:sequence>
<xs:element ref="DateValue"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="DateValue">
<xs:complexType>
<xs:attribute name="Year" type="xs:string"/>
<xs:attribute name="Month" type="xs:string"/>
<xs:attribute name="Day" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="DualValue">
<xs:complexType>
<xs:attribute name="Value1" type="xs:string" use="required"/>
<xs:attribute name="Value2" type="xs:string" use="required"/>
<xs:attribute name="Unit" type="xs:string" use="required"/>
<xs:attribute name="UnitName" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="Duration">
<xs:complexType>
<xs:sequence>
<xs:element ref="SingleValue"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="EventPayment">
<xs:complexType>
<xs:sequence>
<xs:element ref="CaseAttribute" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:string" use="required"/>
<xs:attribute name="TypeId" type="xs:string" use="required"/>
<xs:attribute name="TypeIdName" type="xs:string"/>
<xs:attribute name="Identifies" type="xs:string"/>
<xs:attribute name="Locale" type="xs:string"/>
<xs:attribute name="AddedByPOSRequest" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="Explanation">
<xs:complexType>
<xs:attribute name="ExpressionClass" type="xs:string"
use="required"/>
<xs:attribute name="ExpressionId" type="xs:string" use="required"/>
<xs:attribute name="Addition" default="None">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="None"/>
<xs:enumeration value="Negative"/>
<xs:enumeration value="Unknown"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="PersistentExplanationId" type="xs:string"/>
<xs:attribute name="Text" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="IdBeforeTermChange">
<xs:complexType>
<xs:sequence>
<xs:element ref="DBRefValue"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ListValue">
<xs:complexType>
<xs:choice>
<xs:element ref="BoolValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="DateValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="DualValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="AggregateValue"/>
<xs:element ref="SingleValue"/>
</xs:choice>
<xs:element ref="PeriodValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="StringValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="TimeValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="DBRefValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="CORefValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="ListValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="SetValue" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="MissingInfo">
<xs:complexType>
<xs:attribute name="CaseAttributeTypeId" type="xs:string"
use="required"/>
<xs:attribute name="CaseAttributeTypeIdName" type="xs:string"/>
<xs:attribute name="SourceTypeId" type="xs:string"/>
<xs:attribute name="SourceTypeIdName" type="xs:string"/>
<xs:attribute name="CaseObject" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="Payment">
<xs:complexType>
<xs:sequence>
<xs:element ref="CaseAttribute" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:string" use="required"/>
<xs:attribute name="TypeId" type="xs:string" use="required"/>
<xs:attribute name="TypeIdName" type="xs:string"/>
<xs:attribute name="Identifies" type="xs:string"/>
<xs:attribute name="Locale" type="xs:string"/>
<xs:attribute name="AddedByPOSRequest" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="PeriodValue">
<xs:complexType>
<xs:sequence>
<xs:element ref="DateFrom" minOccurs="0"/>
<xs:element ref="DateTo" minOccurs="0"/>
<xs:element ref="Duration" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="PosRequest">
<xs:complexType>
<xs:sequence>
<xs:element ref="IdBeforeTermChange" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:string" use="required"/>
<xs:attribute name="ModuleId" type="xs:string" use="required"/>
<xs:attribute name="ModuleName" type="xs:string"/>
<xs:attribute name="GeneratedInSource" type="xs:string"
use="required"/>
<xs:attribute name="RelatedCaseObject" type="xs:string"
use="required"/>
<xs:attribute name="SuppressedByAskedOnce" type="xs:string"/>
<xs:attribute name="SuppressedByResult">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="Yes"/>
<xs:enumeration value="No"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="CancelledAtNode" type="xs:string"/>
<xs:attribute name="GeneratedByModuleChange" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="Result">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="CaseRisk" minOccurs="0"/>
<xs:element ref="RiskCaseObjectRelation" minOccurs="0"/>
<xs:element ref="CaseObject" minOccurs="0"/>
<xs:element ref="Benefit" minOccurs="0"/>
<xs:element ref="EventPayment" minOccurs="0"/>
<xs:element ref="Payment" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:string" use="required"/>
<xs:attribute name="CSP" type="xs:string" use="required"/>
<xs:attribute name="Locale" type="xs:string" use="required"/>
<xs:attribute name="NumberOfSourceChanges" type="xs:string"
use="required"/>
<xs:attribute name="NumberOfChangeAssessCycles" type="xs:string"
use="required"/>
<xs:attribute name="ResultLevelId" type="xs:string" use="required"/>
<xs:attribute name="ResultLevelIdName" type="xs:string"/>
<xs:attribute name="PolicyCanBeIssued">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="Yes"/>
<xs:enumeration value="No"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="AssessmentDate" type="xs:string"
use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="RiskCaseObjectRelation">
<xs:complexType>
<xs:attribute name="From" type="xs:string" use="required"/>
<xs:attribute name="To" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="SetValue">
<xs:complexType>
<xs:choice>
<xs:element ref="BoolValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="DateValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="DualValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="AggregateValue"/>
<xs:element ref="SingleValue"/>
</xs:choice>
<xs:element ref="PeriodValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="StringValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="TimeValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="DBRefValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="CORefValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="ListValue" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="SetValue" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="SingleValue">
<xs:complexType>
<xs:attribute name="Value" type="xs:string" use="required"/>
<xs:attribute name="Unit" type="xs:string"/>
<xs:attribute name="UnitName" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="Source">
<xs:complexType>
<xs:attribute name="Id" type="xs:string" use="required"/>
<xs:attribute name="TypeId" type="xs:string" use="required"/>
<xs:attribute name="TypeIdName" type="xs:string"/>
<xs:attribute name="RelatedCaseObject" type="xs:string"
use="required"/>
<xs:attribute name="DefaultSource">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="Yes"/>
<xs:enumeration value="No"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Complete">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="Yes"/>
<xs:enumeration value="No"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="StringValue">
<xs:complexType>
<xs:attribute name="Value" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="TimeValue">
<xs:complexType>
<xs:attribute name="Hour" type="xs:string" use="required"/>
<xs:attribute name="Minute" type="xs:string" use="required"/>
<xs:attribute name="Second" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>
 
S

stylusstudio

Hi -

There's a way to automatically generate java wrapper classes for your
various XML schema data constructs using JAXB - the java architecture
for XML binding (it's the Java standard way of doing this kind of thing
- there are other approaches though). Read this tutorial to learn more:
http://www.stylusstudio.com/jaxb.html

The tool is integrated with the Stylus Studio XML Schema Editor:
http://www.stylusstudio.com/xml_schema_editor.html

Sincerely,
The Stylus Studio Team
http://www.stylusstudio.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top