- From: David E. Cleary <davec@progress.com>
- Date: Tue, 19 Jun 2001 10:23:23 -0400
- To: <sandygao@ca.ibm.com>, <xmlschema-dev@w3.org>
> -----Original Message----- > From: xmlschema-dev-request@w3.org > [mailto:xmlschema-dev-request@w3.org]On Behalf Of sandygao@ca.ibm.com > Sent: Tuesday, June 19, 2001 9:18 AM > To: xmlschema-dev@w3.org > Subject: attributes with prefix in schema > > > Hi all. I'm trying to understand how to process attributes with prefix in > schema. > > The following segment is from "schema for schemas": > > <xs:complexType name="openAttrs"> > <xs:annotation> > <xs:documentation> > This type is extended by almost all schema types > to allow attributes from other namespaces to be > added to user schemas. > </xs:documentation> > </xs:annotation> > <xs:complexContent> > <xs:restriction base="xs:anyType"> > <xs:anyAttribute namespace="##other" processContents="lax"/> > </xs:restriction> > </xs:complexContent> > </xs:complexType> > > I have three questions: > > 1. "This type is extended by almost all schema types to allow attributes > from other namespaces to be added to user schemas." How about attributes > from the schema namespace? For example: > <xsd:element name="ele" type="xsd:string" xsd:use="invalid"/> > Is "xsd:use" considered to be the same as "use", or is it not allowed to > appear? There are two problems here. First and foremost, the ##other wildcard means any namespace other than the target namespace. Secondly, attributes are unqualified in the XSD schema, so xsd:use is not the same as use and will cause a validation error. > 3. Notice that processContents="lax", so it means we should validate those > attributes if we can find the declarations. Then where are we supposed to > find such declarations? Consider an example: > > <xsd:schema xmlns:xsd="..." xmlns:test="test" targetNamespace="test"> > <xsd:attribute name="att" type="xsd:decimal"/> > <xsd:element name="ele" test:att="invalid"/> > </xsd:schema> > > Then are we supposed to validate "test:att" against the type > "xsd:decimal"? Lax means if you have a schema for that namespace, use it. Otherwise, do not validate. How you get that schema is up to the application or tools you are using. XSV takes schemas as command line parameters. MSXML uses a schema collection object. If these questions are related to development of the Xerces C++ parser, please see a message I posted to the Xerces list concerning a Schema Resolver interface. Reliance on schemaLocation as is currently the case with Xerces is completly inadequate. Whenever a namespace is declared, the application should be informed of that fact and be allowed to retrieve a schema for that namespace. So for instance, in your example, when xmlns:test="test" is decalared, an interface like EntityResolver is called. Your application sees the namespace URI that has just come in scope and has the option of providing a schema for it. Then, test:att will be validated. David Cleary
Received on Tuesday, 19 June 2001 10:23:27 UTC