Using schema to validate xml file segment

Discussion in 'XML' started by Aaron P Frenger, Nov 4, 2004.

  1. 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 ()
     
    Aaron P Frenger, Nov 4, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page