XML - XSD验证错误:可用于验证的根
没有匹配的全局声明我有我试图使用CDA架构基础设施,以验证XML文件。XML - XSD验证错误:可用于验证的根
$domxml = new DOMdocument();
$domxml->load($fil);
if($domxml->SchemaValidate('filepath/cda/POCD_MT000040_SDTC.xsd')) {
//do stuff
} else {
print_recursive(libxml_get_errors())
}
我的XML文件具有以下标题:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="ccda.xsl"?>
<ClinicalDocument
xsi:schemaLocation="urn:hl7-org:v3
http://xreg2.nist.gov:8080/hitspValidation/schema/cdar2c32/infrastructure/cda/C32_CDA.xsd"
xmlns="urn:hl7-org:v3"
xmlns:sdtc="urn:hl7-org:sdtc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<realmCode code="US"/>
<typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/>
我的XSD文件具有以下标题:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema targetNamespace="urn:hl7-org:v3"
xmlns:mif="urn:hl7-org:v3/mif"
xmlns="urn:hl7-org:v3"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
xmlns:sdtc="urn:hl7-org:sdtc">
通过的libxml提供的错误消息是这样:
Error 1845: Line: 1 Col: 0: Element '{urn:hl7-org:v3}ClinicalDocument': No matching global declaration available for the validation root.
我已经看了这个错误消息的其他例子出现了,这是一个非常模糊的错误,在我的搜索中,这意味着大约15种不同的,完全矛盾的事情 - 但是我缩小了它的头或者头中的错误为XSD。我不认为我在PHP中加载或验证它不正确,但我可能会误解。
我被告知使用此文件(及其包含的所有文件)作为我正在使用的XML文档的XSD验证程序,所以我不确定如果我做错了什么(下载在XSD文件,将它们上传到服务器,指着他们使用的DOMDocument schemavalidate),或者如果我的XML文件头是错误的(不可能的,因为我所提供的测试用例应该按照他们的标准正常工作),或者是XSD错误的(也许我抓住了错误的?)
谢谢您可以提供任何帮助!
不知道我应该要回答我的问题,但我在这里把它留在万一有人跑进了同样的问题。
分析这一些之后,我环顾四周,不同版本的CDA XSD的 - 并最终找到一个包含以下行的文件(CDA_SDTC.xsd):
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by Bob Dolin (HL7 CDA TC) -->
<xs:schema targetNamespace="urn:hl7-org:v3" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sdtc="urn:hl7-org:sdtc" xmlns="urn:hl7-org:v3" xmlns:mif="urn:hl7-org:v3/mif"
elementFormDefault="qualified">
<xs:annotation>
<xs:documentation>Manually edited to add SDTC Schema Extension (authenticator/signatureText, legalAuthenticator/signatureText), 14 July 2013</xs:documentation>
<xs:documentation>Manually edited to add SDTC Schema Extensions, July 2012</xs:documentation>
</xs:annotation>
<xs:include schemaLocation="POCD_MT000040_SDTC.xsd"/>
<xs:element name="ClinicalDocument" type="POCD_MT000040.ClinicalDocument"/>
</xs:schema>
文件这包括(POCD_MT000040_SDTC.xsd)是我粘贴的上述报头中的XSD和关键的是,该文件包括线
<xs:element name="ClinicalDocument" type="POCD_MT000040.ClinicalDocument"/>
其是类型声明我需要实际开始处理XSD。现在验证完全反对这种新CDA_SDTC.xsd文件(当它不应该不验证!)