在XML文件中指定本地XSD架构

时间:2013-10-22 10:32:28

标签: eclipse xsd

我需要验证XML文件并使用eclipse来完成它。我已将XML文件和所有XSD文件添加到项目中: enter image description here

我添加了对XSD文件的引用:

<?xml version="1.0" encoding="UTF-8"?>
<S2SDDDnf:MPEDDDnfBlkDirDeb xmlns = "MPEDDDnfBlkDirDeb.xsd">


    <S2SDDDnf:SndgInst>stuff</S2SDDDnf:SndgInst>
    <S2SDDDnf:RcvgInst>stuff</S2SDDDnf:RcvgInst>
    <S2SDDDnf:SrvcId>COR</S2SDDDnf:SrvcId>
    <S2SDDDnf:TstCode>T</S2SDDDnf:TstCode>
    <S2SDDDnf:FType>DNF</S2SDDDnf:FType>
    <S2SDDDnf:FileRef>DNFMJMD%R5%LXXX</S2SDDDnf:FileRef>
    <S2SDDDnf:FileBusDt>2013-10-18</S2SDDDnf:FileBusDt>
    <S2SDDDnf:RoutingInd>ALL</S2SDDDnf:RoutingInd>
    <S2SDDDnf:FileCycleNo>01</S2SDDDnf:FileCycleNo>
    <S2SDDDnf:NumDDBlk>1</S2SDDDnf:NumDDBlk>
    <S2SDDDnf:NumPCRBlk>0</S2SDDDnf:NumPCRBlk>
    <S2SDDDnf:NumREJBlk>0</S2SDDDnf:NumREJBlk>

    <S2SDDDnf:FIToFICstmrDrctDbt xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.003.001.02"
                          xmlns:S2SDDDnf="urn:S2SDDDnf:xsd:$MPEDDDnfBlkDirDeb">

    <GrpHdr>
        <MsgId>DNF.UAIAO47X2B</MsgId>
        <CreDtTm>2013-10-18T15:40:00</CreDtTm>
        <NbOfTxs>1</NbOfTxs>
        <TtlIntrBkSttlmAmt Ccy="EUR">1025.00</TtlIntrBkSttlmAmt>
        <IntrBkSttlmDt>2013-10-22</IntrBkSttlmDt>
        <SttlmInf>
            <SttlmMtd>CLRG</SttlmMtd>
            <ClrSys>
                <Prtry>ST2</Prtry>
            </ClrSys>
        </SttlmInf>
        <InstdAgt>
            <FinInstnId>
                <BIC>stuff</BIC>
            </FinInstnId>
        </InstdAgt>
    </GrpHdr>

<DrctDbtTxInf>
    <PmtId>
        <InstrId>DDPreTest18</InstrId>
      <EndToEndId>TS141GENR-ZLDL%R5%WXXX</EndToEndId>
      <TxId>TRXID01.R8NRO%R4%D</TxId>
    </PmtId>
    <PmtTpInf>
        <SvcLvl>
            <Cd>SEPA</Cd>
        </SvcLvl>
        <LclInstrm>
            <Cd>CORE</Cd>
        </LclInstrm>
        <SeqTp>OOFF</SeqTp>
    </PmtTpInf>
    <IntrBkSttlmAmt Ccy="EUR">1025.00</IntrBkSttlmAmt>
    <ChrgBr>SLEV</ChrgBr>
    <ReqdColltnDt>2013-10-22</ReqdColltnDt>
    <DrctDbtTx>
        <MndtRltdInf>
            <MndtId>Mndt141.001b</MndtId>
            <DtOfSgntr>2013-09-16</DtOfSgntr>
            <AmdmntInd>false</AmdmntInd>
            <AmdmntInfDtls>
                <OrgnlCdtrSchmeId>
                    <Id>
                        <PrvtId>
                            <Othr>
                                <Id></Id>
                            </Othr>
                        </PrvtId>
                    </Id>
                </OrgnlCdtrSchmeId>
            </AmdmntInfDtls>
        </MndtRltdInf>
        <CdtrSchmeId>
            <Id>
                <PrvtId>
                    <Othr>
                        <Id>stuff</Id>
                        <SchmeNm><Prtry>SEPA</Prtry></SchmeNm>
                    </Othr>
                </PrvtId>
            </Id>
        </CdtrSchmeId>
    </DrctDbtTx>
    <Cdtr>
        <Nm>stuff</Nm>
    </Cdtr>
    <CdtrAcct>
        <Id>
            <IBAN>stuff</IBAN>
        </Id>
    </CdtrAcct>
    <CdtrAgt>
        <FinInstnId>
            <BIC>stuff</BIC>
        </FinInstnId>
    </CdtrAgt>
    <Dbtr>
        <Nm>stuff</Nm>
    </Dbtr>
    <DbtrAcct>
        <Id>
            <IBAN>stuff</IBAN>
        </Id>
    </DbtrAcct>
    <DbtrAgt>
        <FinInstnId>
            <BIC>stuff</BIC>
        </FinInstnId>
    </DbtrAgt>
    <RmtInf>
        <Ustrd>Pre-testing SEPA Direct Debits</Ustrd>
    </RmtInf>
</DrctDbtTxInf>
</S2SDDDnf:FIToFICstmrDrctDbt>
</S2SDDDnf:MPEDDDnfBlkDirDeb>

这是XSD:

<?xml version="1.0" encoding="UTF-8"?>
<!-- STEP2 SDD Schema, MPEDDDnfBlkDirDeb, May 25th 2012,  Release November 2012  -->
<!-- STEP2 SDD Shift camt.056 after pacs.003 in sequence and counter, February 25th 2010 -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sw3="urn:iso:std:iso:20022:tech:xsd:pacs.003.001.02" xmlns:sw2="urn:iso:std:iso:20022:tech:xsd:pacs.002.001.03" xmlns:sw6="urn:iso:std:iso:20022:tech:xsd:camt.056.001.01" xmlns:S2SDDDnf="urn:S2SDDDnf:xsd:$MPEDDDnfBlkDirDeb" targetNamespace="urn:S2SDDDnf:xsd:$MPEDDDnfBlkDirDeb" elementFormDefault="qualified">
    <xs:import namespace="urn:iso:std:iso:20022:tech:xsd:pacs.003.001.02" schemaLocation="pacs.003.001.02.xsd"/>
    <xs:import namespace="urn:iso:std:iso:20022:tech:xsd:pacs.002.001.03" schemaLocation="pacs.002.001.03.xsd"/>
    <xs:import namespace="urn:iso:std:iso:20022:tech:xsd:camt.056.001.01" schemaLocation="camt.056.001.01.xsd"/>
    <xs:element name="MPEDDDnfBlkDirDeb">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="SndgInst" type="sw3:BICIdentifier"/>
                <xs:element name="RcvgInst" type="sw3:BICIdentifier"/>
                <!-- changed from SrvcID to SrvcId, Febrary 12 2009 -->
                <xs:element name="SrvcId" type="S2SDDDnf:SrvcID"/>
                <xs:element name="TstCode" type="S2SDDDnf:TestCodeType"/>
                <xs:element name="FType" type="S2SDDDnf:FTpType"/>
                <xs:element name="FileRef" type="S2SDDDnf:Max16Text"/>
                <xs:element name="FileBusDt" type="sw2:ISODate"/>
                <xs:element name="RoutingInd" type="S2SDDDnf:RoutingInd"/>
                <xs:element name="FileCycleNo" type="S2SDDDnf:Max2NumericText"/>
                <xs:element name="NumDDBlk" type="S2SDDDnf:Max8NumericText"/>
                <xs:element name="NumPCRBlk" type="S2SDDDnf:Max8NumericText"/>
                <xs:element name="NumREJBlk" type="S2SDDDnf:Max8NumericText"/>
                <xs:element name="FIToFICstmrDrctDbt" type="sw3:FIToFICustomerDirectDebitV02" minOccurs="0" maxOccurs="unbounded"/>
                <!--camt.056.001.01 replace pacs.006.001.02, January 20th 2010 -->
                <xs:element name="FIToFIPmtCxlReq" type="sw6:FIToFIPaymentCancellationRequestV01" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element name="FIToFIPmtStsRpt" type="sw2:FIToFIPaymentStatusReportV03" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:simpleType name="Max16Text">
        <xs:restriction base="xs:string">
            <xs:pattern value="[0-9A-Z]{16,16}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="SrvcID">
        <xs:restriction base="xs:string">
            <xs:enumeration value="COR"/>
            <xs:enumeration value="B2B"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="FTpType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="DNF"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TestCodeType">
        <xs:restriction base="xs:string">
            <xs:length value="1"/>
            <xs:enumeration value="T"/>
            <xs:enumeration value="P"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="Max8NumericText">
        <xs:restriction base="xs:string">
            <xs:pattern value="[0-9]{1,8}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="RoutingInd">
        <xs:restriction base="xs:string">
            <xs:length value="3" fixed="true"/>
            <xs:enumeration value="DIR"/>
            <xs:enumeration value="IND"/>
            <xs:enumeration value="ALL"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="Max2NumericText">
        <xs:restriction base="xs:string">
            <xs:pattern value="[0-9]{2,2}"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

收到此错误:

The prefix "S2SDDDnf" for element "S2SDDDnf:MPEDDDnfBlkDirDeb" is not bound.    SDDCoreTest18.xml   /XMLValidation  line 2  XML Problem



修改
在单独的文件夹中组织XSD文件:

enter image description here

2 个答案:

答案 0 :(得分:1)

您需要添加S2SDDDnf别名的定义,如下所示:

<S2SDDDnf:MPEDDDnfBlkDirDeb xmlns = "MPEDDDnfBlkDirDeb.xsd" xmlns:S2SDDDnf="urn:S2SDDDnf:xsd:$MPEDDDnfBlkDirDeb">...</S2SDDDnf:MPEDDDnfBlkDirDeb>

答案 1 :(得分:0)

尝试使用“新建XML文件”向导创建引用XSD的XML文件。