- From: Liz Castro <lcastro@cookwood.com>
- Date: Fri, 11 Aug 2000 22:59:27 -0400
- To: www-xml-schema-comments@w3.org
- CC: marting@develop.com
> Re: namespaces and schemaLocation > > From: Martin Gudgin (marting@develop.com) > Date: Thu, Aug 10 2000 > > <snip> > > Back to the way XSD works; it is the value of the targetNamespace attribute > that determines which namespace top level schema components are in ( named > types, global element decls, global attribute decls etc ). Namespace > declarations ( xmlns= xmlns:pre= etc ) have no effect on which namespace the > schema components belong to. They just allow us to refer to the schema > components. For example if I had a named type 'foo' in the namespace > 'http://example.org/something' and I wanted to provide a global element > declaration I need someway of refering to foo in that namespace: > > <schema xmlns='http://www.w3.org/1999/XMLSchema' > xmlns:tns='http://example.org/something' > targetNamespace='http://example.org/something' > > > <complexType name='foo'> > <element name='bar' type='string' /> > </complexType> > > <element name='baz' type='tns:foo' /> > > </schema> > > Note that in the above schema both 'foo' and 'baz' are in the > http://example.org/something namespace while 'bar' is in no namespace > because all local element and attribute decls are, by default, in no > namespace. How does this affect the namespace that you are creating (by writing the schema)? How can you define a namespace with a schema if those local elements and attributes are not associated with the target namespace? Or maybe my problem is in thinking that a schema defines a namespace? > The schema below is equivalent, but I *never* write schemas this way. Why not? I'd like to explain how to write them this way since most of the examples in the primer are set up this way (and also because it seems more clear to see all of the elements that are related to the schema of schemas prefixed with xsd). > I > pretty much always map the default namespace to > http://www.w3.org/1999/XMLSchema: > > <xsd:schema xmlns:xsd='http://www.w3.org/1999/XMLSchema' > xmlns='http://example.org/something' > targetNamespace='http://example.org/something' > > > <xsd:complexType name='foo'> > <xsd:element name='bar' type='xsd:string' /> > </xsd:complexType> > > <xsd:element name='baz' type='foo' /> > > </schema> > <snip> Thanks, Liz Liz Castro Cookwood Press http://www.cookwood.com/
Received on Friday, 11 August 2000 22:53:05 UTC