|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Recursive section validation
Hi I am very much an xsd/xml newbie. I have seen examples of recursive definitions of xml sections that will validate xml of the general form: <section> <thing_1>...</thing_1> <thing_2>...</thing_2> <section type=folder> <thing_1>...</thing_1> <thing_2>...</thing_2> </section> <section type=folder> <thing_1>...</thing_1> <thing_2>...</thing_2> <section type=file> <thing_1>...</thing_1> <thing_2>...</thing_2> </section> <section type=file> <thing_1>...</thing_1> <thing_2>...</thing_2> </section> </section> </section> I have a task to create an xsd for xml that is being generated by an application that I do not control... read that as: I can not change the format of the xml. Things I know: - Any "<section>" tag may have zero or more "attributes", for example: <section> <section type="foo"> <section type="foo" id="abcdefg" srcPath="/abcd/ef/ghi">> - If a "<section>" tag has any attributes then it will have one called "type=". It can have more attributes but only one of each kind. - Each "section" block can contain any combination of simple elements or other sub-sections. Ok, for my xml-newbie brain that is more than enough to chew on. For real "validation" though there is a complication. The "type" attribute is actually a hint that determines which other attributes can or should appear in the "section" tag and it also is the key to what "<thing...>" or sub-section elements are contained within. Is it possible to write and xsd for this sort of recursive structure where an attribute value drives the validation? My instinct says no. If I had control of the program internals that generates the xml I might consider "promoting" the "type=" attributes up to replace the "section" tags -- making each more unique. As an example I'll modify the example above: <section> <thing_1>...</thing_1> <thing_2>...</thing_2> <FOLDER> <thing_1>...</thing_1> <thing_2>...</thing_2> </FOLDER> <FOLDER> <thing_1>...</thing_1> <thing_2>...</thing_2> <FILE> <thing_1>...</thing_1> <thing_2>...</thing_2> </FILE> <FILE> <thing_1>...</thing_1> <thing_2>...</thing_2> </FILE> </FOLDER> </section> Unfortunately, I can not do this. Do I have any other options?
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||






