Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: Using non-native attributes

From: "Priscilla Walmsley" <priscilla@--------.--->
To: "'David Morris'" <dmmorris@-----.--->, <xmlschema-dev@--.--->
Date: 12/7/2004 6:56:00 AM
Hi David,

I have been able to get this to work using Xerces, by adding the schema for
schemas, as you were trying to do. For example:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:doc="http://example.org/doc"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://example.org/doc example0606.xsd
                               http://www.w3.org/2001/XMLSchema
http://www.w3.org/2001/XMLSchema.xsd">
  <xsd:element  name="test" type="xsd:integer"
                doc:description="This element represents a product."/>
</xsd:schema>

Perhaps the problem was that when you set the external schema location
property, you only used the schema location, when it should be target
namespace, followed by whitespace, followed by the schema location.

I will update example in the book to include the reference to the schema for
schemas, and add it to the errata.  Also note that some processors have
problems validating schemas against the schema for schemas, because there
are a few glitches in it. At least there were at one time - I haven't looked
at it very recently.

You can also use non-native attributes in your schemas without validating
them, though, because by default they are laxly validated.

Hope that helps!
Priscilla

-----------------------------------------------------
Priscilla Walmsley             priscilla@w...
Author, Definitive XML Schema     (Prentice Hall PTR)
-----------------------------------------------------  

> -----Original Message-----
> From: xmlschema-dev-request@w... 
> [mailto:xmlschema-dev-request@w...] On Behalf Of David Morris
> Sent: Tuesday, December 07, 2004 1:32 AM
> To: xmlschema-dev@w...
> Subject: Using non-native attributes
> 
> 
> 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"
>         xmlns:doc="http://example.org/doc"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xsi:schemaLocation="http://example.org/doc example0606.xsd">
>    <xsd:element name="product" type="xsd:string" 
>             doc:description="This element represents a product."/>
> </xsd:schema>
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>         xmlns="http://example.org/doc"
>         targetNamespace="http://example.org/doc">
>    <xsd:attribute name="description" type="xsd:string"/>
> </xsd:schema>
> 
> 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());
>        builder.setFeature(
>            "http://apache.org/xml/features/validation/schema",
>            true);
>        builder.setProperty(
>            
> "http://apache.org/xml/properties/schema/external-schemaLocation",
>            "http://www.w3.org/2001/XMLSchema.xsd");
>        Document doc = builder.build(xmlFile);
> 
> Thanks for your help,
> 
> David Morris
> 
> 
> 



From brs@i... Wed Dec 08 13:58:13 2004
Received: from lisa.w3.org ([128.30.52.41])
	by frink.w3.org with esmtp (Exim 4.34)
	id 1Cc2Kb-00


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent