2012-02-28 124 views
1

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

第一个模式:

 
<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="Document" type="Document"/> 
    .... 
     <xs:complexType name="GroupHeader33"> 
     <xs:sequence> 
      <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:sequence> 
      <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"/> 
     
    

对不起,我的英语:)

回答

相关问题