[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Including schema with target namespace

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Tue, 10 Feb 2009 07:16:24 -0500
Message-Id: <7.0.1.0.2.20090210071415.0262e8f8@wheresmymailserver.com>
To: xmlschema-dev@w3.org
Re: Including schema with target namespace

At 2009-02-09 12:07 -0500, Bob Kline wrote:
>We've got XML documents which look (greatly simplified) like this:
>
><?xml version='1.0' encoding='utf-8'?>
><TopLevelElement cdr:ref='...' otherAttribute='...'>...</TopLevelElement>
>
>None of the element names and few of the attribute names in the 
>documents include colons.
>...
>In an attempt to migrate from DTD validation to XML Schema 
>validation, we're running into a stumbling block.  Since each schema 
>document can have at most only one target namespace, we've put the 
>definitions for the cdr prefixed attributes in one schema document, 
>which has a target namespace.  We then include that document in the 
>schema document for the rest of the elements and types.

Sounds good to me.

>Schema processors won't accept this, complaining that  "[t]he target 
>namespace of the included/redefined schema 
>'CdrNamespaceAttributes.xml' has to be absent, since the 
>including/redefining schema has no target namespace."
>
>If that's so, how do we go about validating a document which looks 
>like the one above using XML Schema?

You don't show us what your schema looks like, which makes it 
difficult to guide you as to where you went wrong.

Below is a working example that might reveal for you where you went 
wrong in your own code.

I hope this helps.

. . . . . . . . . . Ken

T:\ftemp>type kline.xml
<TopLevelElement xmlns:cdr="urn:x-cdr" cdr:ref='...' 
otherAttribute='...'>...</TopLevelElement>

T:\ftemp>type kline.xsd
<?xml version="1.0" encoding="US-ASCII"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:cdr="urn:x-cdr">

<xsd:import namespace="urn:x-cdr" schemaLocation="klinecdr.xsd"/>

<xsd:element name="TopLevelElement">
   <xsd:complexType mixed="true">
     <xsd:attribute ref="cdr:ref"/>
     <xsd:attribute name="otherAttribute" type="xsd:string"/>
   </xsd:complexType>
</xsd:element>

</xsd:schema>

T:\ftemp>type klinecdr.xsd
<?xml version="1.0" encoding="US-ASCII"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             targetNamespace="urn:x-cdr"
             xmlns:cdr="urn:x-cdr">

<xsd:attribute name="ref" type="xsd:string"/>

</xsd:schema>

T:\ftemp>w3cschema-all kline.xsd kline.xml
Xerces...
No validation errors.
Saxon...
Altova...
The XML data is valid

T:\ftemp>

--
Upcoming hands-on XSLT, UBL & code list hands-on training classes:
Brussels, BE 2009-03;  Prague, CZ 2009-03, http://www.xmlprague.cz
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/x/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal
Received on Tuesday, 10 February 2009 12:17:29 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.