简体   繁体   中英

XML - XSD validation error: No matching global declaration available for the validation root

I have an XML file I am attempting to validate using the CDA schema infrastructure.

$domxml = new DOMdocument();
$domxml->load($fil);
if($domxml->SchemaValidate('filepath/cda/POCD_MT000040_SDTC.xsd')) {
//do stuff
} else {
     print_recursive(libxml_get_errors())
}

My XML file has the following header:

<?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"/>

My XSD file has the following header:

<?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">

The error message as provided by libxml is as such:

Error 1845: Line: 1 Col: 0: Element '{urn:hl7-org:v3}ClinicalDocument': No matching global declaration available for the validation root.

I've looked at other examples of this error message appearing, and it's a very ambiguous error that has, in my searching, meant about 15 different, completely contradictory things - but I've narrowed it down to either a mistake in the headers for the XML or the headers for the XSD. I don't think I'm loading or validating it incorrectly in PHP, but I could be mistaken.

I was told to use this file (and all the files it includes, which are present) as the XSD validator for the XML document I am using, so I'm not certain if I'm doing something wrong (Downloaded the XSD files, uploaded them to server, pointed at them using domdocument schemavalidate), or if my XML file headers are wrong (unlikely, as I'm being provided test cases that should function correctly per their standards), or if the XSD is wrong (maybe I grabbed the wrong one?)

Thank you for any assistance you can provide!

Not sure if I'm supposed to be answering my own question, but I'm leaving it here in case someone runs into the same issue.

After analyzing this some more, I looked around for a different version of the CDA XSD - and ended up finding one that included a file (CDA_SDTC.xsd) with the following lines:

<?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>

The file this includes (POCD_MT000040_SDTC.xsd) is the XSD I pasted the header of above, and crucially, this file includes the line

<xs:element name="ClinicalDocument" type="POCD_MT000040.ClinicalDocument"/>

which is the type declaration I needed to actually start processing the XSD. It now validates perfectly against this new CDA_SDTC.xsd file (and doesn't validate when it shouldn't!)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM