如何在使用jaxb进行编组时,将xml中的元素名称更改为从另一个xsd中定义的元素到另一个xsd中定义的元素

时间:2014-01-31 09:37:12

标签: xml jaxb marshalling

我正在从XBRL网站下载的架构中创建XBRL实例报告。元素“item”,它是复杂类型anyType,在xbrl-instance-2003-12-31.xsd中定义。

以下是适用于“item”元素的类型之一

货币项目类型适用于“item”元素的复杂类型之一。

<complexType name="monetaryItemType" final="extension">
  <simpleContent>
    <extension base="xbrli:monetary">
      <attributeGroup ref="xbrli:numericItemAttrs"/>
    </extension>
 </simpleContent>
</complexType>

下面是模式的一部分,它给出了“item”和根元素的类型。

<element name="item" type="anyType" abstract="true">
  <annotation>
    <documentation>
      Abstract item element used as head of item substitution group
    </documentation>
 </annotation>
</element>
<element name="tuple" type="anyType" abstract="true">
 <annotation>
  <documentation>
      Abstract tuple element used as head of tuple substitution group
  </documentation>
 </annotation></element>
<element name="xbrl">
  <annotation>
    <documentation>
      XBRL instance root element.
    </documentation>
  </annotation>
<complexType>
  <sequence>
    <element ref="link:schemaRef" minOccurs="1" maxOccurs="unbounded"/>
    <element ref="link:linkbaseRef" minOccurs="0" maxOccurs="unbounded"/>
    <element ref="link:roleRef" minOccurs="0" maxOccurs="unbounded"/>
    <element ref="link:arcroleRef" minOccurs="0" maxOccurs="unbounded"/>
     <choice minOccurs="0" maxOccurs="unbounded">
       <element ref="xbrli:item"/>
       <element ref="xbrli:tuple"/>
       <element ref="xbrli:context"/>
       <element ref="xbrli:unit"/>
       <element ref="link:footnoteLink"/>
     </choice>
   </sequence>
   <attribute name="id" type="ID" use="optional"/>
   <anyAttribute namespace="http://www.w3.org/XML/1998/namespace" processContents="lax"/>           
 </complexType>
</element>

上述模式的“item”元素应具有下述外部模式中任一元素的名称

以下是外部架构的摘录。

 <xsd:schema targetNamespace="http://sbr.gov.au/icls/baf/bafot/bafot.02.12.data"    elementFormDefault="qualified">
  <xsd:import namespace="http://sbr.gov.au/fdtn/sbr.02.15.dtyp" schemaLocation="../../../fdtn /dtyp.sbr.02.15.xsd"/>
  <xsd:import namespace="http://sbr.gov.au/fdtn/sbr.01.02.tech" schemaLocation="../../../fdtn/tech.sbr.01.02.xsd"/>
 <xsd:import namespace="http://www.xbrl.org/2003/instance" schemaLocation="http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd"/>

<xsd:element name="bafotAbstract" id="bafot.02.12_bafotAbstract" type="xbrli:stringItemType"  substitutionGroup="xbrli:item" abstract="true" xbrli:periodType="instant"/>
<xsd:element name="FinancialRisk.AdjustmentAndExclusionStatus.Indicator" id="DE13052" type="xbrli:booleanItemType" block="substitution" substitutionGroup="xbrli:item" nillable="true" xbrli:periodType="instant"/>
<xsd:element name="FinancialRisk.AdjustmentStatus.Indicator" id="DE12828" type="xbrli:booleanItemType" block="substitution" substitutionGroup="xbrli:item" nillable="true" xbrli:periodType="instant"/>
<xsd:element name="FinancialRisk.AggregationBenefit.Amount" id="DE12829" type="xbrli:monetaryItemType" block="substitution" substitutionGroup="xbrli:item" nillable="true" xbrli:balance="debit" xbrli:periodType="instant"/>
<xsd:element name="FinancialRisk.AggregationBenefitLifeBusiness.Amount" id="DE12830" type="xbrli:monetaryItemType" block="substitution" substitutionGroup="xbrli:item" nillable="true" xbrli:balance="debit" xbrli:periodType="instant"/>
<xsd:element name="FinancialRisk.APRAApprovedAdjustmentsToLMICRC.Amount" id="DE12831" type="xbrli:monetaryItemType" block="substitution" substitutionGroup="xbrli:item" nillable="true" xbrli:balance="credit" xbrli:periodType="instant"/>
<xsd:element name="FinancialRisk.CatastropheReinsuranceEnd.Date" id="DE13050" type="xbrli:dateItemType" block="substitution" substitutionGroup="xbrli:item" nillable="true"        
<xsd:element name="FinancialRisk.CatastropheReinsuranceStart.Date" id="DE13051" type="xbrli:dateItemType" block="substitution" substitutionGroup="xbrli:item" nillable="true" xbrli:periodType="instant"/>
<xsd:element name="FinancialRisk.ChargeAdjustment.Amount" id="DE12832" type="xbrli:monetaryItemType" block="substitution" substitutionGroup="xbrli:item" nillable="true" xbrli:balance="credit" xbrli:periodType="instant"/>
<xsd:element name="FinancialRisk.CumulativeExposuresAdjustment.Amount" id="DE12863" type="xbrli:monetaryItemType" block="substitution" substitutionGroup="xbrli:item" nillable="true" xbrli:balance="credit" xbrli:periodType="instant"/>
<xsd:element name="FinancialRisk.DeductionsForNetPremiumsLiability.Amount" id="DE12864" type="xbrli:monetaryItemType" block="substitution" substitutionGroup="xbrli:item" nillable="true" xbrli:balance="credit" xbrli:periodType="instant"/>
<xsd:element name="FinancialRisk.DeterminationBasis.Code" id="DE13053" type="dtyp.02.15:sbrDeterminationBasisCodeItemType" block="substitution" substitutionGroup="xbrli:item" nillable="true" xbrli:periodType="instant"/>

如何将结果xml中item元素的名称更改为外部模式中的任何一个元素名称。我不确定如何实现这一点,请帮助解决此问题。向下加载所有外部模式并生成类型并将它们实例化以作为项添加是一种选择,但由于此类外部模式的数量和大小,它是不可行的。还有其他方法可以实现同样的目标。

0 个答案:

没有答案