Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Newbie: schema on local file system

Reply
Thread Tools

Newbie: schema on local file system

 
 
maxwell@ldc.upenn.edu
Guest
Posts: n/a
 
      02-20-2007
I'm trying to develop a schema, and test it on some sample data.
There are plenty of examples out there on how to develop schemas etc.,
but they all seem to assume that you give a URI for the schema that
points to a web address. For now, I do not have the schema in a web-
accessible place, it's just on the local file system. I'm stuck
trying to specify the xmlns inside the file.

If I have the schema in the same directory as the xml data file, I can
get away with the following first lines in the xml data file (that is,
it passes muster with xmllint)

<?xml version="1.0"?>
<Mo:MorphologicalData xmlns:Mo="Morph.xsd">...

But if I try for more generality--like putting all my schemas in a
single directory somewhere else--I can't seem to pull it off. That
is, if I replace the above couple lines in my xml data file with the
following:
<?xml version="1.0"?>
<Mo:MorphologicalData
xmlns:Mo="file:///home/mmaxwell/Data/LinguisticSchemas/
Morph.xsd">
--then xmllint gives me an error msg:
> /usr/bin/xmllint --noout --noent --schema Morph.xsd

MorphTestData.xml
MorphTestData.xml:4: element MorphologicalData: Schemas validity
error :
Element 'Mo:MorphologicalData': No matching global declaration
available.

(This is on a Linux file system, and I know the .xsd file exists in
the specified directory.)

I tried searching for "file:///" on line to get some examples of how
to do this, but all of the search engines I tried strip off the
":///", even though I quote it, so I get a bunch of irrelevant hits
with the word "file" in them. Just pointing me to some examples would
probably suffice.

Mike Maxwell

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      02-20-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I'm trying to develop a schema, and test it on some sample data.
> There are plenty of examples out there on how to develop schemas etc.,
> but they all seem to assume that you give a URI for the schema that
> points to a web address. For now, I do not have the schema in a web-
> accessible place, it's just on the local file system. I'm stuck
> trying to specify the xmlns inside the file.


I think you do not understand that a namespace is simply denoted by a
URL. There does not have to be any resource at that URL and usually or
at least often is not. So http://www.w3.org/1999/xhtml is the namespace
URL for XHTML 1. And http://www.w3.org/2000/svg the one for SVG 1.x.
Nevertheless while you can browser to those URLs you will not find a
schema there, just a HTML document giving some info on the namespace.

Schema location URL and namespace URL can be different.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
usenet@tech-know-ware.com
Guest
Posts: n/a
 
      02-20-2007
On 20 Feb, 17:06, "(E-Mail Removed)" <(E-Mail Removed)>
wrote:
> If I have the schema in the same directory as the xml data file, I can
> get away with the following first lines in the xml data file (that is,
> it passes muster with xmllint)
>
> <?xml version="1.0"?>
> <Mo:MorphologicalData xmlns:Mo="Morph.xsd">...
>
> But if I try for more generality--like putting all my schemas in a
> single directory somewhere else--I can't seem to pull it off. That
> is, if I replace the above couple lines in my xml data file with the
> following:
> <?xml version="1.0"?>
> <Mo:MorphologicalData
> xmlns:Mo="file:///home/mmaxwell/Data/LinguisticSchemas/
> ...


Although technically the namespace 'URI' is a URI, in practice it is
just treated as an opague string. Two namespace URIs are considered
the same if, after white space handling and entity expansion, they are
identical character-by-character. There is no attempt made to
dereference the URI.

For example, http://example.com, http://example.com/, http://www.example.com
and http://example.com/index.html may all result in the same resource
being shown. And if there happened to be a schema there, they would
all result in the same schema being returned. However, from a
namespace point of view they all represent different namespaces.

So you probably want to do something like:

<?xml version="1.0"?>
<Mo:MorphologicalData xmlns:Mo="http://mycompany.com/
Morph.xsd">...

If you want to specify in an XML instance how a schema is found, then
you can use the xsi:schemaLocation and xsi:noSchemaLocation
attributes, along the lines of:

<?xml version="1.0"?>
<Mo:MorphologicalData xmlns:Mo="http://mycompany.com/Morph.xsd"
xmlnssi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocation=''file:///home/mmaxwell/Data/
LinguisticSchemas/Morph.xsd">...

This is optional though, and the schemaLocation is only considered to
be a 'hint'.

HTH,

Pete.
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx
(or http://www.xml2cpp.com)
=============================================


 
Reply With Quote
 
maxwell@ldc.upenn.edu
Guest
Posts: n/a
 
      02-21-2007
On Feb 20, 2:10 pm, (E-Mail Removed) wrote:
> If you want to specify in an XML instance how a schema is found, then
> you can use the xsi:schemaLocation and xsi:noSchemaLocation
> attributes, along the lines of:
>
> <?xml version="1.0"?>
> <Mo:MorphologicalData xmlns:Mo="http://mycompany.com/Morph.xsd"
> xmlnssi="http://www.w3.org/2000/10/XMLSchema-instance"
> xsi:schemaLocation=''file:///home/mmaxwell/Data/
> LinguisticSchemas/Morph.xsd">...


This gives me a different error msg from xmllint:
MorphTestData.xml:7: element MorphologicalData:
Schemas validity error : Element 'Mo:MorphologicalData':
The attribute 'xsi:schemaLocation' is not allowed.
MorphTestData.xml fails to validate.
(Incidently, I'm assuming the line break between "Data/" and
"LinguisticSchemas/" is an artifact of email, although somewhere I
vaguely recall that the path and the filename were supposed to be
separated--not sure why??)

> This is optional though, and the schemaLocation is only considered
> to be a 'hint'.


A hint to whom or what? I was assuming that this was an _instruction_
to a validation program, but maybe I'm misunderstanding the purpose...

Mike Maxwell

 
Reply With Quote
 
usenet@tech-know-ware.com
Guest
Posts: n/a
 
      02-21-2007
On 21 Feb, 01:55, "(E-Mail Removed)" <(E-Mail Removed)>
wrote:
> On Feb 20, 2:10 pm, (E-Mail Removed) wrote:
>
> > <?xml version="1.0"?>
> > <Mo:MorphologicalData xmlns:Mo="http://mycompany.com/Morph.xsd"
> > xmlnssi="http://www.w3.org/2000/10/XMLSchema-instance"
> > xsi:schemaLocation=''file:///home/mmaxwell/Data/
> > LinguisticSchemas/Morph.xsd">...

>
> This gives me a different error msg from xmllint:
> MorphTestData.xml:7: element MorphologicalData:
> Schemas validity error : Element 'Mo:MorphologicalData':
> The attribute 'xsi:schemaLocation' is not allowed.
> MorphTestData.xml fails to validate.


Ooops - cut and paste error on my part. I must have opened the wrong
version of the XSD spec. The xmlnssi attribute should be:

xmlnssi="http://www.w3.org/2001/XMLSchema-instance"

Sorry about that.

> (Incidently, I'm assuming the line break between "Data/" and
> "LinguisticSchemas/" is an artifact of email, although somewhere I
> vaguely recall that the path and the filename were supposed to be
> separated--not sure why??)


yep - e-mail artifact!

> > This is optional though, and the schemaLocation is only considered
> > to be a 'hint'.

>
> A hint to whom or what? I was assuming that this was an _instruction_
> to a validation program, but maybe I'm misunderstanding the purpose...


It's a hint to the validation processor. It's along the lines of
"Look here for the schema, but if you don't find it there, don't
complain."

HTH,

Pete.
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx
(or http://www.xml2cpp.com)
=============================================


 
Reply With Quote
 
maxwell@ldc.upenn.edu
Guest
Posts: n/a
 
      02-21-2007
> Schema location URL and namespace URL can be different.

You're right, I totally didn't understand--thanks for the help!

Mike Maxwell

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with schema-validation and property "http://apache.org/xml/properties/schema/external-schemaLocation" Markus Java 1 11-23-2005 02:41 PM
Playing a local mpeg file from a local HTML file... Lyndon HTML 1 07-25-2005 02:21 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
How to specify file on local disk with external schema pohmart@yahoo.com XML 2 03-17-2005 12:37 AM
How to specify a local (!) Schema file in the same (!) directory as the xml file ? Till Soerensen XML 1 06-09-2004 08:55 AM



Advertisments