[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Schema constraints from a different file?
Dmitry Epstein said: .. > Basically, I would like to develop schemas that impose > constraints on an element or attribute in one XML file based on > element or attribute values from another XML file. Is this at > all possible? I would consider making a file containing just a > list of all available item IDs, if that would help solve the > problem. XML Schemas are defined over single files. Therefore you have four basic options 1) Use some other schema language which allows inter-document constraints. Subchoices: 1a) Use Schematron 1b) Use Schematron embedded in your XML schema 1c) Use hand-written XSLT or Java or some other programming language. 1d) Store both data and list in the same XML database then have an integrity constraint (e.g. written using XQuery) for this 2) Make a new larger document out of all the different data documents, and validate that. Subchoices 2a) Make sure the real documents have no DOCTPE declaration, then make your new head document have just <!DOCTYPE dummy [ <!ENTITY idlist SYSTEM "URL of IDs"> <!ENTITY data SYSTEM "URL of data"> ]><dummy>&idlist;&data;</dummy> 2b) Similar effect, except use XInclude 2c) Similar effect, except use XSLT, m4, cpp or some transformation preprocessor 3) Make a larger schema incorporating the IDs. Subchoices: 2b) Use xsd:include and an external file with the schema 3b) Use xsd:include and put external file at a URL. Maintain the list in your preferred format but have the webserver send it through an XSLT transformer first. In general, the more "tricky" constraints (where "tricky" is defined as the repetitive and voluminous class of constraints XML Schemas is hopeless at) you have, the more you will want to use 1). Cheers Rick Jelliffe
|
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
|