1

我在为不同的模式映射一个模型对象(例如:GroupHeader)时遇到问题。这个模式中的每一个都有不同的命名空间,但是一些复杂类型在它们中的每一个中都有几乎相同的结构。所以我想将此元素映射到一个 java 对象。是否可以使用 JAXB 来实现这一点?

第一个架构:

<xs:schema xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.02" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified " targetNamespace="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.02">
    <xs:element name="文档" type="文档"/>
    ……
       <xs:complexType name="GroupHeader33">
        <xs:序列>
            <xs:element name="MsgId" type="Max35Text"/>
            <xs:element name="CreDtTm" type="ISODateTime"/>
           <xs:element maxOccurs="1" minOccurs="0" name="BtchBookg" type="BatchBookingIndicator"/>
            <xs:element name="NbOfTxs" type="Max15NumericText"/>
            <xs:element maxOccurs="1" minOccurs="0" name="CtrlSum" type="DecimalNumber"/>
            <xs:element maxOccurs="1" minOccurs="0" name="TtlIntrBkSttlmAmt" type="ActiveCurrencyAndAmount"/>
            <xs:element maxOccurs="1" minOccurs="0" name="IntrBkSttlmDt" type="ISODate"/>
            <xs:element name="SttlmInf" type="SettlementInformation13"/>
            <xs:element maxOccurs="1" minOccurs="0" name="PmtTpInf" type="PaymentTypeInformation21"/>
            <xs:element maxOccurs="1" minOccurs="0" name="InstgAgt" type="BranchAndFinancialInstitutionIdentification4"/>
            <xs:element maxOccurs="1" minOccurs="0" name="InstdAgt" type="BranchAndFinancialInstitutionIdentification4"/>
        
    
    ...
    

第二种模式:

<xs:schema xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.004.001.02" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified " targetNamespace="urn:iso:std:iso:20022:tech:xsd:pacs.004.001.02">
   ...
      <xs:complexType name="GroupHeader38">
        <xs:序列>
            <xs:element name="MsgId" type="Max35Text"/>
            <xs:element name="CreDtTm" type="ISODateTime"/>
            <xs:element maxOccurs="2" minOccurs="0" name="Authstn" type="Authorisation1Choice"/>
            <xs:element maxOccurs="1" minOccurs="0" name="BtchBookg" type="BatchBookingIndicator"/>
            <xs:element name="NbOfTxs" type="Max15NumericText"/>
            <xs:element maxOccurs="1" minOccurs="0" name="CtrlSum" type="DecimalNumber"/>
            <xs:element maxOccurs="1" minOccurs="0" name="GrpRtr" type="TrueFalseIndicator"/>
            <xs:element maxOccurs="1" minOccurs="0" name="TtlRtrdIntrBkSttlmAmt" type="ActiveCurrencyAndAmount"/>
            <xs:element maxOccurs="1" minOccurs="0" name="IntrBkSttlmDt" type="ISODate"/>
            <xs:element name="SttlmInf" type="SettlementInformation13"/>
            <xs:element maxOccurs="1" minOccurs="0" name="InstgAgt" type="BranchAndFinancialInstitutionIdentification4"/>
            <xs:element maxOccurs="1" minOccurs="0" name="InstdAgt" type="BranchAndFinancialInstitutionIdentification4"/>
        
    

对不起我的英语不好:)

4

1 回答 1

0

You can use MOXy's external mapping document to apply multiple mappings do your domain model:

The following example demonstrates how to handle. If differences:

And this example demonstrates how to handle small differences:

于 2012-02-28T16:01:37.907 回答