Page 1 of 1

XSD Validation error

Posted: Tue Dec 10, 2013 10:39 pm
by sgraunke
I am a bit new to the use of Oxygen and have a pretty complex XML document that I have inherited.
This file includes numerous external XSD schema references and namespaces.
The issue that I am having is that when I create an XSD using Oxygen it actually creates two files, first it creates the schema instance related to the XML file (same file name.xsd, CDA.XSD here) but it also creates a XSI.XSD file which is where the problem lies...

The error that I am getting is:

System ID: C:\Development\MMG\HFM\20131202\Sample Documents\xsi.xsd
Main validation file: C:\Development\MMG\HFM\20131202\Sample Documents\Summary sample 20131201-2.xsd
Engine name: Xerces
Severity: error
Description: no-xsi: The {target namespace} of an attribute declaration must not match 'http://www.w3.org/2001/XMLSchema-instance'.
Start location: 4:4
End location: 4:16
URL: http://www.w3.org/TR/xmlschema-1/#no-xsi


The start of the CDA.XML looks as follows:

<ClinicalDocument
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hl7-org:v3 ../../90%20HL7/00%20Standard%20-%20C-CDA/20130409%20C-CDA%20R1dot1_2012JUL/Updated_CDA_Schema_Files_Extension_Support/CDA_Schema_Files/infrastructure/cda/CDA_SDTC.xsd"
xmlns="urn:hl7-org:v3"
xmlns:cda="urn:hl7-org:v3"
xmlns:sdtc="urn:hl7-org:sdtc">

The resultant CDA.XSD has the following:

<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="urn:hl7-org:v3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cda="urn:hl7-org:v3">
<xs:import namespace="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="xsi.xsd"/>
<xs:element name="ClinicalDocument">
<xs:complexType>
<xs:attribute ref="xsi:schemaLocation" use="required"/>
</xs:complexType>
</xs:element>

The contents of generated XSI.XSD are:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cda="urn:hl7-org:v3">
<xs:import namespace="urn:hl7-org:v3" schemaLocation="Summary sample 20131201-2.xsd"/>
<xs:attribute name="schemaLocation"/>
<xs:attribute name="type" type="xs:NCName"/>
</xs:schema>

I guess that it is pretty obvious that the error is being caused by the XSI.XSD that was generated when creating the CDA.XSD schema attempting to create a new "Schema definition schema" with the same namespace as XMLSchema-instance.

I found another reference to a similar problem but cannot relate it to the issue that I am having.

http://www.oxygenxml.com/forum/topic616.html

And someone else referencing a similar issue and calling it an issue with TRANG generating the XSD schema...

http://stackoverflow.com/questions/8843 ... -using-xjc

Is there something in the original XML that is causing this?
Or is there some way to avoid this without having to manually edit the resultant XSD files?
Any input to aide in resolution would be greatly appreciated,

Thanks,

Scott

Re: XSD Validation error

Posted: Tue Dec 10, 2013 11:30 pm
by adrian
Hi,

You mentioned you've inherited this XML and since this looks like an XML instance of a properly defined XML schema (CDA_SDTC.xsd), I would advise you to first look around the files you've inherited for this XML schema.
If you locate the schema, all you need to do is write an XML catalog that resolves the schema location URI from your XML instance to the location of your local copy of the schema. Sometimes, an XML catalog may already be available with the schema (usually named catalog.xml or something similar).

If there's no way around it and you must reverse engineer the schema out of the XML instance, you will have to remove the
xmlns:xsi and xsi:schemaLocation declarations from the XML prior to attempting to generate the schema.

Regards,
Adrian