我正在尝试像生成XML一样简单的事情,该过程遵循XML模式的规则。但是,我自己还没有指定XSD文件,并且只是给出了XML标头应如何显示的示例,但是由于某种原因,例如,无法自动找到该架构。 Notepad ++或在我的C#项目中按XmlReaderSettings
。
这里是我的XML的示例:
<?xml version="1.0" encoding="utf-8"?>
<PBSXML000:FullDelivery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pbs-erhverv.dk/online/xml/bs/pbsxml000bigmax http://pbs-erhverv.dk/online/xml/bs/pbsxml000bigmax.xsd" xmlns:PBSXML000="http://pbs-erhverv.dk/online/xml/bs/pbsxml000bigmax">
<PBSXML000:DeliveryStart>
<PBSXML000:DataSupplierCVR>00000</PBSXML000:DataSupplierCVR>
<PBSXML000:DataSupplierSysCode>000</PBSXML000:DataSupplierSysCode>
<PBSXML000:DeliveryId>12345678</PBSXML000:DeliveryId>
<PBSXML000:DeliveryCreateDate>211119</PBSXML000:DeliveryCreateDate>
</PBSXML000:DeliveryStart>
<PBSXML000:SectionStart>
<PBSXML000:CreditorPBSNr>12345678</PBSXML000:CreditorPBSNr>
<PBSXML000:SectionNr>0112</PBSXML000:SectionNr>
<PBSXML000:DebtorGroupNr>1</PBSXML000:DebtorGroupNr>
</PBSXML000:SectionStart>
<PBSXML000:DebtorIdentification>
<PBSXML000:DebtorCustomerNr>99100045</PBSXML000:DebtorCustomerNr>
<PBSXML000:AgreementNr>999100012</PBSXML000:AgreementNr>
<PBSXML000:DuePayDate>01122019</PBSXML000:DuePayDate>
<PBSXML000:DebtorCVROrCPRNr>12345678</PBSXML000:DebtorCVROrCPRNr>
</PBSXML000:DebtorIdentification>
<PBSXML000:M601Record>
<PBSXML000:RecordType022>
<PBSXML000:DebtorNameAddr1>Hans Ole, blalba 17, st th</PBSXML000:DebtorNameAddr1>
<PBSXML000:DebtorPostCode>2100</PBSXML000:DebtorPostCode>
<PBSXML000:DebtorCountryCode>DK</PBSXML000:DebtorCountryCode>
</PBSXML000:RecordType022>
<PBSXML000:RecordType042>
<PBSXML000:SignCode>1</PBSXML000:SignCode>
<PBSXML000:Amount>100095</PBSXML000:Amount>
</PBSXML000:RecordType042>
<PBSXML000:RecordType052>
<PBSXML000:TextNoteRecordNr>11335</PBSXML000:TextNoteRecordNr>
<PBSXML000:TextLine>Ost - den gode</PBSXML000:TextLine>
</PBSXML000:RecordType052>
</PBSXML000:M601Record>
<PBSXML000:DebtorIdentification>
<PBSXML000:DebtorCustomerNr>12345</PBSXML000:DebtorCustomerNr>
<PBSXML000:AgreementNr>12345</PBSXML000:AgreementNr>
<PBSXML000:DuePayDate>01122019</PBSXML000:DuePayDate>
<PBSXML000:DebtorCVROrCPRNr>12345678</PBSXML000:DebtorCVROrCPRNr>
</PBSXML000:DebtorIdentification>
<PBSXML000:SectionEnd>
<PBSXML000:Amountin601>1334690</PBSXML000:Amountin601>
</PBSXML000:SectionEnd>
<PBSXML000:DeliveryEnd>
<PBSXML000:NrOfAll042in601>54</PBSXML000:NrOfAll042in601>
<PBSXML000:TotalAmountin601>0</PBSXML000:TotalAmountin601>
<PBSXML000:NrOfAll052in601>32</PBSXML000:NrOfAll052in601>
<PBSXML000:NrOfAll022in601>22</PBSXML000:NrOfAll022in601>
</PBSXML000:DeliveryEnd>
</PBSXML000:FullDelivery>
并且模式文件的标题是这个:
<xs:schema xmlns:PBSXML000="http://pbs-erhverv.dk/online/xml/bs/pbsxml000bigmax" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://pbs-erhverv.dk/online/xml/bs/pbsxml000bigmax" elementFormDefault="qualified" attributeFormDefault="unqualified">
当我尝试测试时,只会得到错误:
无法在以下位置找到主模式资源>
'http://pbs-erhverv.dk/online/xml/bs/pbsxml000bigmax.xsd'
你知道为什么这个简单的事情失败了吗?
我正在尝试像生成XML一样简单的事情,该过程遵循XML模式的规则。但是,我自己还没有指定XSD文件,只是给了我一个例子,说明我的标题...
您的XML通过xsi:schemaLocation
正确指定了关联的XSD。我能够验证它并确定:
[好,我找到了一种解决方法,我可以将url中的架构专门添加到xsd中,虽然它并不完美,但是我可以忍受它:)如果有人有类似的问题,我刚刚使用过: