- From: Bob Schloss <rschloss@us.ibm.com>
- Date: Fri, 16 Aug 2002 15:18:54 -0400
- To: mrbannon@swen.uwaterloo.ca, xmlschema-dev@w3.org
A schema validator will not check that the content of an attribute matches the constraints specified unless it knows that the element on which the attribute appears has a content model that needs to be checked, and that model calls for that particular attribute, or a class of attributes, to be checked. Therefore, if your schema, or another schema which uses <include> to make use of your schema, had said <xsd:element name="shipTo" type="checkAttributesType"/> <xsd:element name="billTo" type="checkAttributesType"/> <xsd:complexType name="checkAttributesType"> <xsd:simpleContent> <xsd:extension base="xsd:string"> <xsd:attribute ref="test:data_item"/> <xsd:attribute ref="test:ontology_class"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> this should have worked. You could also use <xsd:anyAttribute> when you define checkAttributesType. You could also use a simple content base type with a facet like maxLength is 0 or another mechanism if you wanted to insure that the element content is empty. Bob XML/XSL Transformational Systems IBM Thomas J. Watson Research Center Yorktown Heights, New York USA mrbannon@swen.uwaterloo.ca@w3.org on 08/16/2002 02:34:46 PM Sent by: xmlschema-dev-request@w3.org To: xmlschema-dev@w3.org cc: Subject: newbie question Hi, I've got a really simple problem that I can't seem to fix. Basically, I want to create a schema that only defines attributes. I've done this in the following schema (prototype.xsd): <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.swen.uwaterloo.ca/~mrbannon"> <xsd:attribute name="data_item" type="xsd:boolean"/> <xsd:attribute name="ontology_class" type="xsd:string"/> </xsd:schema> I believe this is valid...please let me know if it's not. My instance is the following: <?xml version="1.0"?> <purchaseOrder xmlns:test="http://www.swen.uwaterloo.ca/~mrbannon" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.swen.uwaterloo.ca/~mrbannon http://www.swen.uwaterloo.ca/~mrbannon/prototype.xsd"> <shipTo country="US" test:ontology_class="blahblah"></shipTo> <billTo country="US" test:data_item="false"></billTo> </purchaseOrder> When I run it through the online validator and change the value of "test:data_item" to gibberish ("lsjdflsdjkfsldj"), I'm told that it's valid and well-formed. How can this be if data_item is to be a boolean? Thanks in advance, Ryan ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/
Received on Friday, 16 August 2002 15:20:42 UTC