Hi there, I'll let Andy respond about "unique". With respect to Peter's example, however, I do get validation errors when I run it thru the parser (1.3.0). I used SAXCount to try this out:
java sax.SAXCount -v first.xml The validation error I got was: [Error] first.xml:6:14: The content of element type "test_root" must match "(failure,name, address,age)". first.xml: 3295 ms (4 elems, 2 attrs, 16 spaces, 21 chars) Peter, are you sure you had validation enabled? Thx, Lisa. "Peter Tornberg" <[EMAIL PROTECTED]> on 02/07/2001 09:42:58 AM Please respond to [EMAIL PROTECTED] To: <[EMAIL PROTECTED]> cc: Subject: SV: support for <unique> ? I'm not sure if attributes for zip can have the same value or not. Still I agree with you from the results of my own tests. To me it seems like the validation only checks to see if the XML schema is valid xml or not. It does not check if the xml document is formatted correctly according to the schema. A simple example which is validated with no errors: first.xml ------------ <?xml version="1.0" encoding="UTF-8"?> <test_root xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="first.xsd"> <name>Peter Tornberg</name> <address>Home</address> <age>100</age> </test_root> first.xsd ------------ <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"> <xsd:element name="test_root"> <xsd:complexType> <xsd:sequence> <xsd:element name="failure" type="xsd:string"/> <xsd:element name="name" type="xsd:string"/> <xsd:element name="address" type="xsd:string"/> <xsd:element name="age" type="xsd:integer"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> /Peter -----Ursprungligt meddelande----- Fr�n: Rebekah Lepro <[EMAIL PROTECTED]> Till: [EMAIL PROTECTED] <[EMAIL PROTECTED]> Datum: den 6 februari 2001 23:00 �mne: support for <unique> ? I've been trying to get validation to fail after violating the unique requirement in a schema, and it doesn't seem to fail no matter what I do. I took the example from the Schema primer too, and it fails. I see that support is still experimental. Is this not yet supported or am I doing something wrong? I've included the schema and the document that I thought would fail validation because of the duplication within the code attribute of zip. But it passes just fine? Thanks, Rebekah Schema document: <?xml version="1.0" encoding="UTF-8"?> <x:schema xmlns:x="http://www.w3.org/2000/10/XMLSchema" elementFormDefault ="qualified" xmlns:r="http://www.example.com/Report"> <x:element name="purchaseReport"> <x:complexType> <x:sequence> <x:element minOccurs="1" maxOccurs="10" name="regions" type="RegionsType"/> </x:sequence> </x:complexType> <x:unique name="testing"> <x:selector xpath="regions/zip"/> <x:field xpath="@code"/> </x:unique> </x:element> <x:complexType name="RegionsType"> <x:sequence> <x:element name="zip" maxOccurs="unbounded"> <x:complexType> <x:sequence> <x:element name="part" maxOccurs="unbounded" type="PartType"/> </x:sequence> <x:attribute name="code" type=" x:positiveInteger"/> </x:complexType> </x:element> </x:sequence> </x:complexType> <x:complexType name="PartType"> <x:sequence> <x:element name="foo"/> </x:sequence> <x:attribute name="number" type="x:string"/> <x:attribute name="quantity" type="x:positiveInteger"/> </x:complexType> </x:schema> XML document *********************** <?xml version="1.0" encoding="UTF-8"?> <!-- edited with XML Spy v3.5 NT (http://www.xmlspy.com) by Rebekah Lepro (Penn State University) --> <purchaseReport xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="\\carina\e$\xml\data\Unique.xsd"> <regions> <zip code="12565"> <part number="12" quantity="2"> <foo>hello</foo> </part> <part number="12" quantity="4"> <foo>hi</foo> </part> </zip> <zip code="12565"> <part number="12" quantity="2"> <foo>hello</foo> </part> <part number="12" quantity="4"> <foo>hi</foo> </part> </zip> </regions> </purchaseReport> Rebekah Lepro - [EMAIL PROTECTED] Applied Research Laboratory The Pennsylvania State University P.O. Box 30, State College PA 16804 Phone: +1-814-863-8122 Fax: +1-814-863-1183
