Hi all, i need to develop an XSD for a requirement where an element is recursively defined within itself, but we should specify a constraint that only the upper level element takes a particular value, which can't be taken by the same kind of element when defined as the child of something. For ex: ======================================================= <x> <name>MAIN</name> <y> <x> <name>Some value which should not be MAIN</name> </x> </y> </x> ======================================================== Can somebody help me out as to how i can define such schema using XSD?
1. Create a XSD type for your element 'x' 2. Create a new type extending the 'x' type created in step 1 and enforce your restrictions in this type. 3. In the root element of your xml, use the x type which is restricted (created in step 2) 4. In the element y use the x base type with no restrictions.
Hope it helps..
Regards, Srivatsa Katta
Joined: May 13, 2005
Hi Srivatsa, thanks a lot that really helps me. Thanks again. -Naresh
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Defining XSD for an XML file with constraint on the contents of a tag