Altova Mailing List Archives>Archive Index >xmlschema-dev Archive Home >Recent entries >Thread Prev - Including schema with target namespace from schema with no target namespace [Thread Next] Re: Including schema with target namespace from schema with no target namespaceTo: xmlschema-dev@--.--- Date: 2/10/2009 2:16:00 AM 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@C... 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 From bkline@r... Tue Feb 10 14:04:43 2009 Received: from maggie.w3.org ([193.51.208.68]) by frink.w3.org with esmtp (Exim | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
