You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Ali_baba <su...@yahoo.com> on 2007/05/27 13:24:56 UTC
How to validate XML file with multiple schemas?
I am trying to get a parser (xcerces-c DOM parser) to validate an XML file
that uses
> a schema which includes another schema definition. All I
> want to do is define an attribute in one schema/namespace and
> reference it as a required attribute in another schema. I've
> simplified the example to 3 files: main.xsd includes subMain.xsd, and
> main.xml is my instance doc.
>
> main.xsd (define element foo that requires subMain:type attribute):
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema targetNamespace="http://www.main.com/main"
> xmlns:subMain="http://www.subMain.com/subMain"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> attributeFormDefault="unqualified">
> <xsd:import namespace="http://www.subMain.com/subMain"
> schemaLocation="subMain.xsd"/>
> <xsd:element name="foo">
> <xsd:complexType>
> <xsd:attribute ref="subMain:type" use="required"/>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
>
> subMain.xsd:
> <?xml version="1.0"?>
> <xsd:schema targetNamespace="http://www.subMain.com/subMain"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
xmlns:anotherSchema = "http://www.anotherSchema.com/anotherSchema"
<xsd:import namespace="http://www.anotherSchema.com/anotherSchema"
schemaLocation="anotherSchema.xsd"/>
> <xsd:attribute name="type" type="xsd:string"/>
> </xsd:schema>
>
> main.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:main="http://www.main.com/main"
> xmlns:subMain="http://www.subMain.com/subMain"
> xsi:schemaLocation="http://www.main.com/main main.xsd
> http://www.subMain.com/subMain subMain.xsd"
/>
main.xsd imports subMain.xsd
subMain.xsd imports anotherSchema.xsd
and so on ...
How do i validate it with xerces-c DOM parser ?? any example would be
helpful.
--
View this message in context: http://www.nabble.com/How-to-validate-XML-file-with-multiple-schemas--tf3823377.html#a10824065
Sent from the Xerces - C - Users mailing list archive at Nabble.com.