469,352 Members | 2,107 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

understanding noNamespaceSchemaLocation

XML, Schemas, and XSLT has been part of my life for a number of years
now, but I have always used it in desktop application where I simply
make the noNamespaceSchemaLocation attribute the name of the schema
because it is going to reside in the same location as the xml file.

I am now working on a project that is a bit more complex. Again part
is a desktop application which will not have access to the Internet all
the time, but another part of the project does have access to the
Internet. It is my understanding that within the XML, it is possible
to provide a URL as the namespace name.

How exactly do I go about setting up the XML so that when it is
validated on the desktop application, I can simply provide the schema
like I always have and then on the web it uses the URL as the source.

I don't think my question makes any sense. What I am really looking
for is a good tutorial on just namespaces and how they work. Any
suggestions?

Jan 7 '07 #1
7 8931
ca******@gmail.com wrote:
XML, Schemas, and XSLT has been part of my life for a number of years
now, but I have always used it in desktop application where I simply
make the noNamespaceSchemaLocation attribute the name of the schema
because it is going to reside in the same location as the xml file.

I am now working on a project that is a bit more complex. Again part
is a desktop application which will not have access to the Internet all
the time, but another part of the project does have access to the
Internet. It is my understanding that within the XML, it is possible
to provide a URL as the namespace name.
It's the other way around: a namespace name MUST be a URI. The URI
syntax allows for interpretation as a local filename, either relative to
the current location or absolute to your local hard disk, or as a
network resource (starting with http://, ftp://, etc)...however, the use
of local names is deprecated in namespaces.

I'm afraid noNamespaceSchemaLocation is just an unpleasant kludge: the
Namespaces Spec says "It is not a goal that it [the namespace name] be
directly usable for retrieval of a schema (if any exists)."
How exactly do I go about setting up the XML so that when it is
validated on the desktop application, I can simply provide the schema
like I always have and then on the web it uses the URL as the source.
You need to ask your software manufacturer for any non-standard feature
they may have provided. It's also a bit risky. What happens if the local
copy and the network copy go out of sync?

It's a great pity Schemas were not implemented using the DOCTYPE
declaration like DTDs, then we would have had PUBLIC and SYSTEM catalog
resolution at our disposal. Unfortunately this would have entailed
another TC to ISO 8879 and another tedious decade teaching developers
how to do catalog resolution properly.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Jan 7 '07 #2

Peter Flynn wrote:
ca******@gmail.com wrote:
XML, Schemas, and XSLT has been part of my life for a number of years
now, but I have always used it in desktop application where I simply
make the noNamespaceSchemaLocation attribute the name of the schema
because it is going to reside in the same location as the xml file.

I am now working on a project that is a bit more complex. Again part
is a desktop application which will not have access to the Internet all
the time, but another part of the project does have access to the
Internet. It is my understanding that within the XML, it is possible
to provide a URL as the namespace name.

It's the other way around: a namespace name MUST be a URI. The URI
syntax allows for interpretation as a local filename, either relative to
the current location or absolute to your local hard disk, or as a
network resource (starting with http://, ftp://, etc)...however, the use
of local names is deprecated in namespaces.

I'm afraid noNamespaceSchemaLocation is just an unpleasant kludge: the
Namespaces Spec says "It is not a goal that it [the namespace name] be
directly usable for retrieval of a schema (if any exists)."
Peter,

First off, thank you for your help! I am guessing here, but my
impression is thta things work this way:

Xml with a namespace of: urn:/cartoper/schema1
actual schema name: MyFirstSchema.xsd

When loading MyFirstSchema.xsd into the validator, there will be a way
to tell the validator that it's namespace is urn:/cartoper/schema1.

Or is it that I have to place the urn:/cartoper/schema1 in the schema,
too?

Jan 7 '07 #3
ca******@gmail.com wrote:
Xml with a namespace of: urn:/cartoper/schema1
actual schema name: MyFirstSchema.xsd

When loading MyFirstSchema.xsd into the validator, there will be a way
to tell the validator that it's namespace is urn:/cartoper/schema1.

Or is it that I have to place the urn:/cartoper/schema1 in the schema,
too?
If you want to author a schema defining elements in that namespace then
use targetNamespace="urn:/cartoper/schema1" e.g.

<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:/cartoper/schema1"
elementFormDefault="qualified">
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 7 '07 #4

Martin Honnen wrote:
ca******@gmail.com wrote:
Xml with a namespace of: urn:/cartoper/schema1
actual schema name: MyFirstSchema.xsd
If you want to author a schema defining elements in that namespace then
use targetNamespace="urn:/cartoper/schema1" e.g.

<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:/cartoper/schema1"
elementFormDefault="qualified">
Martin,

Ok, that makes perfect sense, after doing some digging;) The final
questions is: What exactly do I put in the XML? I am using XMLSpy as
my editor. When I assign the schema to the xml file, it generates this
attributes to the root element:

xmlns="urn:/cartoper/schema1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:/cartoper/schema1 D:\<full
path>\MyFirstSchema.xsd"

When I removed the full path from the xsi:schemaLocation attribute
(xsi:schemaLocation="urn:/cartoper/schema1 MyFirstSchema.xsd"), XmlSpy
complains that it is not valid. Do I simply need to leave off the
xsi:schemaLocation? Or is there some way I can still have the xml
point to the schema being in the same directory? I sort of like how
XMLSpy will validate the XML for me, I use it mostly in development.

Jan 7 '07 #5
Anyone?

ca******@gmail.com wrote:
Martin Honnen wrote:
ca******@gmail.com wrote:
Xml with a namespace of: urn:/cartoper/schema1
actual schema name: MyFirstSchema.xsd
If you want to author a schema defining elements in that namespace then
use targetNamespace="urn:/cartoper/schema1" e.g.

<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:/cartoper/schema1"
elementFormDefault="qualified">

Martin,

Ok, that makes perfect sense, after doing some digging;) The final
questions is: What exactly do I put in the XML? I am using XMLSpy as
my editor. When I assign the schema to the xml file, it generates this
attributes to the root element:

xmlns="urn:/cartoper/schema1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:/cartoper/schema1 D:\<full
path>\MyFirstSchema.xsd"

When I removed the full path from the xsi:schemaLocation attribute
(xsi:schemaLocation="urn:/cartoper/schema1 MyFirstSchema.xsd"), XmlSpy
complains that it is not valid. Do I simply need to leave off the
xsi:schemaLocation? Or is there some way I can still have the xml
point to the schema being in the same directory? I sort of like how
XMLSpy will validate the XML for me, I use it mostly in development.
Jan 8 '07 #6
ca******@gmail.com wrote:
Anyone?
>Ok, that makes perfect sense, after doing some digging;) The final
questions is: What exactly do I put in the XML? I am using XMLSpy as
my editor.
You might want to ask XMLSpy specific questions in an XMLSpy user forum
as there you have a better chance to find other users of that software
than in a generic comp.text.xml group.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 8 '07 #7

Martin Honnen wrote:
ca******@gmail.com wrote:
Anyone?
Ok, that makes perfect sense, after doing some digging;) The final
questions is: What exactly do I put in the XML? I am using XMLSpy as
my editor.

You might want to ask XMLSpy specific questions in an XMLSpy user forum
as there you have a better chance to find other users of that software
than in a generic comp.text.xml group.
Martin,

I would agree with you, except, I am trying to understand how exactly
namespaces, schemas, and xml are all tied together, I am assuming the
XMLSpy will comply with the way things are, which is not always the
case;)

Peter's inital reply implies that it is a bad thing to use the
xsi:schemaLocation attribute. Am I correct? Is there any way of
denoting in the xsi:schemaLocation that the schema file is in the same
folder/directory as the XML?

Jan 8 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Balaji V | last post: by
18 posts views Thread by Simon | last post: by
8 posts views Thread by boki_pfc | last post: by
2 posts views Thread by =?ISO-8859-1?Q?Jean=2DFran=E7ois_Michaud?= | last post: by
3 posts views Thread by Samuel | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.