2016-12-02 52 views
1

目前,我正在實現一些接口以從外部系統使用XML數據。我應該收到的數據都是格式良好的XML文檔。但是,問題在於它們都沒有像下面的示例那樣的命名空間。如何在XML模式中引用複雜類型,但沒有targetNamespace

<ReturnOfFileApplicationDetails> 
    <ApplicationNo>APP-2015-1214-000847</ApplicationNo> 
    <CourtOrderRefNo></CourtOrderRefNo> 
    <SourceRequestNo></SourceRequestNo> 
    <Status>A</Status> 
    <RejectionReason></RejectionReason> 
    <CourtEventDetails> 
     <NextCourtNo>26</NextCourtNo> 
     <NextCourtDateTime>201601111500</NextCourtDateTime> 
     <NextCourtJOName></NextCourtJOName> 
    </CourtEventDetails> 
    <IODetails> 
     <Name>CPIB IO</Name> 
     <Designation>Special Investigation Officer</Designation> 
     <DivisionAgency>CPIB</DivisionAgency> 
     <ReportNo></ReportNo> 
     <IPNo></IPNo> 
    </IODetails> 
</ReturnOfFileApplicationDetails> 

因此,從我學會爲止,我不能在XSD架構中使用targetNamespace我建立了描述這些數據。例如,下面是我爲上述有效負載創建的XSD。

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
      xmlns="http://oscar.pactera.com/icms/schema"> 
    <xsd:include schemaLocation="CourtEvent.xsd"/> 
    <xsd:include schemaLocation="InvestigationOfficer.xsd"/> 

    <xsd:complexType name="FileApplication"> 
     <xsd:sequence> 
      <xsd:element name="ApplicationNo" type="xsd:string" minOccurs="0" nillable="true"/> 
      <xsd:element name="ApplicationType" type="xsd:string" minOccurs="0" nillable="true"/> 
      <xsd:element name="CourtOrderRefNo" type="xsd:string" minOccurs="0" nillable="true"/> 
      <xsd:element name="SourceRequestNo" type="xsd:string" minOccurs="0" nillable="true"/> 
      <xsd:element name="CaseNo" type="xsd:string" minOccurs="0" nillable="true"/> 
      <xsd:element name="Status" type="xsd:string" minOccurs="0" nillable="true"/> 
      <xsd:element name="RejectionCode" type="xsd:string" minOccurs="0" nillable="true"/> 
      <xsd:element name="RejectionReason" type="xsd:string" minOccurs="0" nillable="true"/> 

      <xsd:element name="CourtEventDetails" type="CourtEvent" minOccurs="0" maxOccurs="1"/> 
      <xsd:element name="IODetails" type="InvestigationOfficer" minOccurs="0" maxOccurs="1"/> 
     </xsd:sequence> 
    </xsd:complexType> 
    <xsd:element name="ReturnOfFileApplicationDetails" type="FileApplication"/> 
</xsd:schema> 

我現在的問題是,我的IDE抱怨它不能找到複雜類型FileApplication我把爲ReturnOfFileApplicationDetails元素,即使他們是從字面上在同一XSD。由於CourtEvent.xsdInvestigationOfficer.xsd也沒有targetNamespace,所以我的IDE找不到CourtEventInvestigationOfficer複雜類型。

如果您能告訴我我正確地構建了我的XSD而沒有targetNamespace,我將不勝感激。

乾杯,

詹姆斯陳

回答

1

您需要刪除默認的命名空間聲明

xmlns="http://oscar.pactera.com/icms/schema" 
相關問題