tags:

views:

151

answers:

2

I have an application into which users can upload an XSD to describe certain kinds of user data. The application needs to parse this XSD to correctly initialise various bits of database metadata (e.g. translating xs:enumerations into lists of permitted values that will populate drop-down lists). The same user-entered XSD is also used to validate XML documents sent to the application by other systems.

Is it possible to write a master XSD against which I can validate such a user-supplied XSD so that I can limit how users can describe their data and therefore make the job of XSD parsing easier? For example, let's say I wanted to be able to allow users to upload any XSD at all unless it contained xs:union tags. How could I write an XSD that I could use to validate an XSD uploaded by the user to enforce this rule?

+4  A: 

You find it here: http://www.w3.org/2001/XMLSchema.xsd

Just a hint, a schema starts with xsd:schema tag. And if correct, contains an attribute:

xmlns:xsd="http://www.w3.org/2001/XMLSchema"

Follow the url and you find and information page, with a link to the dtd and the xsd.

Gamecat
+1  A: 

I think you'll find this problem much easier if you ignore that the user-supplied files are XSD files and just consider them as XML. After all, XSD files are just XML so you can enforce schema rules on them just like any other.

I would start by looking at the XMLSchema's schema. Using this, you can write your own schema that adds additional demands on your source documents like enforcing all documents have a union.

Jeff Yates