xjc バージョン「2.2.3-hudson-jaxb-ri-2.2-70-」を続けて 2 回使用すると、2 つの異なるコンパイル結果が生成されます。問題は、xjc コンパイル結果 1 の Java ファイルによってマーシャリングされた XML が、xjc コンパイル結果 2 の Java ファイルによってマーシャリングされた XML ファイルとは異なる (そして間違っている) ことです。
結果の XML の違いは、名前空間プレフィックス ns2 での発生/不発生です。
<Activity Id="Id task1" Name="Task 1">
<Implementation>
<ns2:Task/>
</Implementation>
</Activity>
さまざまな結果の XML を担当する Java コードの違いは、@XMLElements での順序の違いです。
次の順序で、名前空間プレフィックスが結果の XML に出現します。
@XmlElements({
@XmlElement(name = "BlockActivity", namespace = "http://www.wfmc.org/2002/XPDL1.0", type = org.wfmc._2002.xpdl1.BlockActivity.class),
@XmlElement(name = "BlockActivity", type = org.wfmc._2008.xpdl2.BlockActivity.class),
次の順序では、結果の XML に名前空間プレフィックスは発生しません。
@XmlElements({
@XmlElement(name = "BlockActivity", type = org.wfmc._2008.xpdl2.BlockActivity.class),
@XmlElement(name = "BlockActivity", namespace = "http://www.wfmc.org/2002/XPDL1.0", type = org.wfmc._2002.xpdl1.BlockActivity.class),
bpmnxpdl_31.xsdをコンパイルします
xjc.bat -verbose -no-header c:\TEMP\bpmnxpdl_31.xsd -b c:\TEMP\binding.xjb
binding.xjb を使用:
<jxb:bindings node="xsd:element[@name='Activity']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Status']/xsd:simpleType">
<jxb:typesafeEnumClass name="Status"/>
</jxb:bindings>
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='StartMode']/xsd:simpleType">
<jxb:typesafeEnumClass name="StartMode"/>
</jxb:bindings>
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='FinishMode']/xsd:simpleType">
<jxb:typesafeEnumClass name="FinishMode"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='ActivitySet']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='AdHocOrdering']/xsd:simpleType">
<jxb:typesafeEnumClass name="AdHocOrdering"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='Artifact']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='ArtifactType']/xsd:simpleType">
<jxb:typesafeEnumClass name="ArtifactType"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='Assignment']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='AssignTime']/xsd:simpleType">
<jxb:typesafeEnumClass name="AssignTime"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='Association']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='AssociationDirection']/xsd:simpleType">
<jxb:typesafeEnumClass name="AssociationDirection"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='BasicType']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Type']/xsd:simpleType">
<jxb:typesafeEnumClass name="Type"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='BlockActivity']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='View']/xsd:simpleType">
<jxb:typesafeEnumClass name="View"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='Condition']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Type']/xsd:simpleType">
<jxb:typesafeEnumClass name="Type"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='ConformanceClass']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='GraphConformance']/xsd:simpleType">
<jxb:typesafeEnumClass name="GraphConformance"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='ConformanceClass']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='BPMNModelPortabilityConformance']/xsd:simpleType">
<jxb:typesafeEnumClass name="BPMNModelPortabilityConformance"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='DataMapping']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Direction']/xsd:simpleType">
<jxb:typesafeEnumClass name="Direction"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='Deadline']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Execution']/xsd:simpleType">
<jxb:typesafeEnumClass name="Execution"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='EndEvent']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Result']/xsd:simpleType">
<jxb:typesafeEnumClass name="Result"/>
</jxb:bindings>
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Implementation']/xsd:simpleType">
<jxb:typesafeEnumClass name="Implementation"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='EndPoint']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='EndPointType']/xsd:simpleType">
<jxb:typesafeEnumClass name="EndPointType"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='FormalParameter']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Mode']/xsd:simpleType">
<jxb:typesafeEnumClass name="Mode"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='Icon']">
<jxb:bindings node="./xsd:complexType/xsd:simpleContent/xsd:extension/xsd:attribute[@name='SHAPE']/xsd:simpleType">
<jxb:typesafeEnumClass name="SHAPE"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='IntermediateEvent']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Trigger']/xsd:simpleType">
<jxb:typesafeEnumClass name="Trigger"/>
</jxb:bindings>
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Implementation']/xsd:simpleType">
<jxb:typesafeEnumClass name="Implementation"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='Join']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Type']/xsd:simpleType">
<jxb:typesafeEnumClass name="Type"/>
</jxb:bindings>
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='ExclusiveType']/xsd:simpleType">
<jxb:typesafeEnumClass name="ExclusiveType"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='Loop']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='LoopType']/xsd:simpleType">
<jxb:typesafeEnumClass name="LoopType"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='LoopMultiInstance']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='MI_Ordering']/xsd:simpleType">
<jxb:typesafeEnumClass name="MI_Ordering"/>
</jxb:bindings>
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='MI_FlowCondition']/xsd:simpleType">
<jxb:typesafeEnumClass name="MI_FlowCondition"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='LoopStandard']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='TestTime']/xsd:simpleType">
<jxb:typesafeEnumClass name="TestTime"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='ParticipantType']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Type']/xsd:simpleType">
<jxb:typesafeEnumClass name="Type"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='Pool']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Orientation']/xsd:simpleType">
<jxb:typesafeEnumClass name="Orientation"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='ProcessHeader']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='DurationUnit']/xsd:simpleType">
<jxb:typesafeEnumClass name="DurationUnit">
<jxb:typesafeEnumMember value="M" name="Month" />
<jxb:typesafeEnumMember value="m" name="Minute" />
</jxb:typesafeEnumClass>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="xsd:element[@name='StartEvent']">
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Trigger']/xsd:simpleType">
<jxb:typesafeEnumClass name="Trigger"/>
</jxb:bindings>
<jxb:bindings node="./xsd:complexType/xsd:attribute[@name='Implementation']/xsd:simpleType">
<jxb:typesafeEnumClass name="Implementation"/>
</jxb:bindings>
</jxb:bindings>
XJC の後続の実行で @XMLElements の安定した順序を取得する方法はありますか?