W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2002

Re: newbie question - attributes

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
Message-ID: <OFFE108BC1.47748BD2-ON85256C17.00693570@us.ibm.com>


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

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:extension base="xsd:string">
        <xsd:attribute ref="test:data_item"/>
        <xsd:attribute ref="test:ontology_class"/>

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.


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
Subject:    newbie question


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"
 <xsd:attribute name="data_item"          type="xsd:boolean"/>
 <xsd:attribute name="ontology_class"     type="xsd:string"/>

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"
    <shipTo country="US" test:ontology_class="blahblah"></shipTo>
    <billTo country="US" test:data_item="false"></billTo>

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
and well-formed.  How can this be if data_item is to be a boolean?

Thanks in advance,


This mail sent through IMP: http://horde.org/imp/
Received on Friday, 16 August 2002 15:20:42 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:04 UTC