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

Re: XML Schema Question

  • From: ht@c... (Henry S. Thompson)
  • To: Brett McLaughlin <bmclaugh@a...>
  • Date: 02 Jan 2000 18:32:23 +0000

Re: XML Schema Question
Brett McLaughlin <bmclaugh@a...> writes:

> My understanding is for XML like this:
> 
> <?xml version="1.0"?>
> 
> <myNamespace:Doc xmlns="Schema/mySchema.xsd" 
>                  xmlns:myNamespace="http://someUrl.com"
> >
> 
>   <myNamespace:element1>
>     <myNamespace:element2 />
>   </myNamespace:element1>
> 
>   <myNamespace:element3>Some content</myNamespace:element3>
> 
> </myNamespace:Doc>
> 
> the myNamespace namespace is of course associated with
> http://someUrl.com.  And the schema for the document that would be used
> for validation would be Schema/mySchema.xsd, as defined in the default
> namespace.  Is that correct?  I know that was the previous version...

This is not quite the right approach.  The default namespace
declaration is doing no work, and is unlikely to yield the right
results.

The preferred approach is as follows:

 <myNamespace:Doc xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance" 
                  xmlns:myNamespace="http://someUrl.com"
                  xsi:schemaLocation="http://someUrl.com
                                      Schema/mySchema.xsd"
 >

The following would also work, in a context where dereferencing
namespace URIs is mandated/encouraged.

 <myNamespace:Doc
    xmlns:myNamespace="http://someUrl.com/Schema/mySchema.xsd"
>

but would require that you use your schema URL as your namespace URI.

> And in my schema (here's where everything changed):
> 
> <?xml version="1.0"?>
> <!DOCTYPE schema
>     PUBLIC 
>       "-//W3C//DTD XML Schema Version 1.0//EN"
>     SYSTEM 
>       "http://www.w3.org/TR/1999/WD-xmlschema-1-19991217/structures.dtd"
> >
> 
> <schema targetNamespace="http://someUrl.com"
>         xmlns="http://www.w3.org/1999/XMLSchema"
>         xmlns:myNamespace="http://someUrl.com"
> >
> 
>   <element name="element1" type="myNamespace:element1Type" />
> 
>   <type name="element1Type">
>     <element name="element2">
>       <type content="empty" />
>     </element>
>   </type>
> 
>   <element name="element3" type="string" />
> 
> </schema>
> 
> That would be right, as I can tell.  My only unsurety is whether it is
> correct to omit the namespace before each element's name (in a DTD, of
> course, this has to be myNamespace:element1 and myNamespace:element2). 
> As far as I can tell, the element is defined, and the namespace listed
> in targetNamespace is then applied to all elements named.  That would be
> why the type element1Type must be referred to as
> myNamespace:element1Type in the definition of the element1 element,
> correct?  The namespace is applied to it.  So can someone let me know if
> I am reading this right, or if I'm off in left field somewhere ;-)

The schema is all correct, and your analysis of the namespace story in 
the schema is correct (see also my message on this subject yesterday [1]).

ht

[1] http://www.lists.ic.ac.uk/hypermail/xml-dev/xml-dev-Jan-2000/0013.html
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@c...
		     URL: http://www.ltg.ed.ac.uk/~ht/

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo@i... the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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-2013 All Rights Reserved.