- From: G. Ken Holman <gkholman@CraneSoftwrights.com>
- Date: Mon, 04 Aug 2003 08:45:33 -0400
- To: "Xmlschema-Dev" <xmlschema-dev@w3.org>
At 2003-08-04 13:17 +0200, Camilla Brenchley wrote: >Given the below schema, is it possible to specify that if the attribute >"Type" equals "Double" then the element "WithDoubleBed" is required, i.e. >minOccurs="1", and if it equals "DoubleOneChild" then the element "ChildAge" >is required? This is a co-occurrence constraint and I believe it cannot be supported in W3C Schema (though it can be supported using RELAX-NG). I'd like to be proven wrong, though, as it a common requirement and applications would be unencumbered with certain validation checking if it were available. I hope this helps. ................. Ken p.s. Here is the RELAX-NG schema: T:\ftemp>type camilla.rnc datatypes x = "http://www.w3.org/2001/XMLSchema-datatypes" start = element TestRoom { element Room { ( attribute Type { "Single" | "Double" } | ( attribute Type { "DoubleOneChild" }, element ChildAge { x:integer } ) ), element WithDoubleBed { x:string }? }+ } # end of file T:\ftemp>type camilla1.xml <TestRoom> <Room Type="Single"> <WithDoubleBed>Yes</WithDoubleBed> </Room> <Room Type="Double"> </Room> <Room Type="DoubleOneChild"> <ChildAge>3</ChildAge> <WithDoubleBed>Yes</WithDoubleBed> </Room> <Room Type="DoubleOneChild"> <WithDoubleBed>Yes</WithDoubleBed> </Room> <Room Type="Double"> <ChildAge>3</ChildAge> </Room> </TestRoom> T:\ftemp>jing -c camilla.rnc camilla1.xml T:\ftemp\camilla1.xml:12: error: required elements missing T:\ftemp\camilla1.xml:15: error: element "ChildAge" not allowed in this context T:\ftemp> -- Upcoming hands-on courses: in-house corporate training available; North America public: XSLT/XPath Aug 12, 2003 G. Ken Holman mailto:gkholman@CraneSoftwrights.com Crane Softwrights Ltd. http://www.CraneSoftwrights.com/x/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-11-X Practical Formatting Using XSL-FO Member of the XML Guild of Practitioners: http://XMLGuild.info Male Breast Cancer Awareness http://www.CraneSoftwrights.com/x/bc
Received on Monday, 4 August 2003 09:21:49 UTC