2012-02-28 120 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"/> 
     
    

對不起,我的英語:)

回答

相關問題