Using schema to validate xml file segment

  • Thread starter Aaron P Frenger
  • Start date
A

Aaron P Frenger

Hello All,

I have a very large XML file that I would like to split up into a few
smaller files, but still use only one schema. I am using Xerces C++
libraries.

My idea is to have one schema specified in the main file. At some
point in the schema I would add a choice element that would either
have a tag that specifies an external file or a tree of tags. Once
the main xml file is loaded I would search for any instances where the
external file tag was populated and load that external file. I would
then want to use the schema specified in the main file to validate it.
Is there a way to move to a specific section of the schema file
specified in the main file and use that section to validate another
xml file?

Example:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="EXAMPLE">
<xs:complexType>
<xs:choice>
<xs:element name="EXTERNAL_FILE_NAME"/>
<xs:element name="TEST_DATA">
<xs:complexType>
<xs:all>
<xs:element name="TEST1"/>
<xs:element name="TEST2"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

In this case if EXTERNAL_FILE_NAME was populated I would read in that
file and validate it against the schema using the sub tree starting at
<xs:element name="TEST_DATA">.

Any suggestions would be appreciated.

Thanks,
Aaron ([email protected])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top