W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2004

Using non-native attributes

From: David Morris <dmmorris@gmail.com>
Date: Mon, 6 Dec 2004 23:31:50 -0700
Message-ID: <b17ae18604120622313aeec620@mail.gmail.com>
To: xmlschema-dev@w3.org

I am trying to use a non-native schema attribute and it doesn't seem
to work how I thought it would. The only reference with substance I
can find on the subject is Priscilla Walmsley's book Definitive XML
Schema. I am trying to annotate a schema with some custom attributes
to validate an idea and have run into some trouble.

When I edit an XML Schema using WebSphere Development Studio's (WDS)
Schema editor, I get an error "Unknown attribute xxx:yyy". After a lot
of trial and error, I downloaded a similar example from the Definitive
XML Schema Web site. That example (chapter 6 5/6) fails with the same
error (and a missing type). At this point, I have to believe that WDS
is unable to work with non-native attributes.

Here is the example XML Document and XML Schema:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xsi:schemaLocation="http://example.org/doc example0606.xsd">
   <xsd:element name="product" type="xsd:string" 
            doc:description="This element represents a product."/>

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   <xsd:attribute name="description" type="xsd:string"/>

The next thing I tried was to use a Java program to programatically
validate this Schema with the XML Schema Schema. I receive the
fillowing "Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot
find the declaration of element 'xsd:schema'." I can use this same
program to validate conventional XML documents against an XML Schema
and it works fine. I am using Xerces 1.6.2 and JDOM 1.0.  I have tried
using an entity resolver to pick up a local copy of XMLSchema.xsd as
well as from the URL: http://www.w3.org/2001/XMLSchema.xsd.

Here is some of the code:

       SAXBuilder builder =
           new SAXBuilder("org.apache.xerces.parsers.SAXParser", true);
     builder.setEntityResolver(new SchemaLoader());
       Document doc = builder.build(xmlFile);

Thanks for your help,

David Morris
Received on Tuesday, 7 December 2004 10:32:03 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:07 UTC