- From: Stefan Wachter <Stefan.Wachter@gmx.de>
- Date: Mon, 30 Dec 2002 17:47:58 +0100 (MET)
- To: Jan Mendling <mendling@web.de>
- Cc: xmlschema-dev@w3.org
Hi Jan, you are absolutely right that the expressiveness of XML schema constraints should be improved and XPath seems to be a natural option. A topic raised several times on this list considers constraints relating several attributes / elements. Some of these constraints could easily be expressed by XPaths. About performance: I think performance matters should not guide the decision about wheter XPath-Constraints should be added to the schema specification or not. If performance is a matter then people can switch of validation (or use only simple constraints). Maybe the XPaths allowed in XPaths-Constraints should be restricted access only descendants and no ancestors or siblings. This might be a compromise to ease the implementation of streaming processors. About raising this topic: I did not explictly raise the XPath constraint topic on this list. Yet, I announced my developments some months ago. Therefore I include now a snippet from the JBind documentation. The example shows how to check the relation of attributes. Bye, --Stefan 5.2.2 XPath Constraints The xPathConstraint extension element uses XPaths to specify constraints on types. The element has two attributes: * select. Optional attribute that contains an XPath that is used to select the data objects to be tested. The XPath is evaluated relative to the current data object, i.e. the data object on whose type the XPath constraint is imposed. If no select attribute is present then the current data object is selected. * test. An arbitrary XPath that is evaluated to a boolean. The XPathConstraint is statisfied iff its XPath evaluates to true for all selected data objects. Note: XPath constraints are equal in concept to the assert mechanism of [Schematron]. The Person type in the example schema uses an XPath constraint to check the cooccurrence of attributes. The select attribute is used only for demonstration because its value corresponds to the default. The relevant part is repeated here for convenience. <complexType name="Person" jb:hasBehaviour="true"> ... <jb:xPathConstraint select="." test="(@extraterrestrial and not(@countryId) and not(@cityId)) or (@countryId and @cityId)"/> ... </complexType> > Hallo Stefan, > > thank you for your hint. Does your constraint-implementation prove me righ > t that there is a need for such a facility in XML Schema in general, not o > nly in my case? I am wondering why it is not integrated in the specificati > on. Even the unique-constraints are just allowed on a subset of Xpath-expr > essions. > A reason could be performance. But what experiences did you make with perf > ormance and overhead costs in validating such Xpath-constraints? It could > not be too much, because you probably just have to consider a set of Xpath > -expression to be true or not. That can even easily be done by XSLT. Thus, > the performance reason cannot count, otherwise the hole Xpath und XSLT wo > uld have to be considered as too expensive. > Did you try to present your concept to spec people pf XML Schema? > > Jan > > > > Stefan Wachter <Stefan.Wachter@gmx.de> schrieb am 30.12.02 16:52:09: > > Hi Jan, > > > > maybe you can express and validate your constraints using Schematron. If > you > > do not care about conformance then you can also use JBind (www.jbind.org > ). I > > augmented the XML schemas with an XPath-Constraint facility. > > > > --Stefan > > > > > > > > > > Hello and merry christmas, > > > > > > I have a design problem with XML Schema. I am in the situation that it > > > > would be very appealing to use something like Constraints (beyond the > > > uniqueness-constraints XML Schema offers with Key, Keyref and Unique). > > > > > > > Therefore, I was wondering whether there are attempts being made to > > > integrate a Constraint-Concept into XML Schema (something that we know > > > from SQL > > > in the database area). In my design situation it would be nice to have > > > > something like Xpath-Constraints. I am thinking of an Xpath-Statement > that > > must > > > evaluate TRUE in order to validate an instance document against that X > ML > > > Schema. With such a mechanism it would be easy to build structures and > > > allow > > > only certain content constellations. > > > > > > By now, I will probably fix my problem by defining a bunch of simple t > ypes > > > which capture these constraints implicitly with the use of regular > > > expressions. A not very elegant solution. > > > > > > Any hints on constraints in any schema-language will be appreciated. I > am > > > looking forward on your commends. > > > > > > Best regards, > > > Jan Mendling > > > > > > > > ________________________________________________________________________ > ______ > > > Kursiv, fett, bunt,... WEB.DE FreeMail kann alles - mit der HTML-Mail > > > http://freemail.web.de/features/?mc=021143 > > > > > > > -- > > ~~~~~~~~~~~~~ > ~ Jan Mendling > ~ Güterstr.53 > ~ 54295 Trier > ~ 0175-1636958 > ~~~~~~~~~~~~~ > __________________________________________________________________________ > ____ > Wenn POP fur Sie mehr als nur Musik ist. Senden Sie Ihre SMS direkt aus > Outlook oder Netscape! http://freemail.web.de/features/?mc=021177 >
Received on Monday, 30 December 2002 11:48:30 UTC