Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Abolishing Namespaces

Reply
Thread Tools

Abolishing Namespaces

 
 
tysontate@gmail.com
Guest
Posts: n/a
 
      08-09-2005
I've been charged with updating old schemas for various files that have
never actually been validated against each other. I've got the schema
itself in good form at this point - I'm positive that they're pretty
clean. My only remaining problem is namespaces.

The XML files, which I can't modify, use no namespaces at all. They
contain elements from as many as four different files. Example:

"CargoList" in CargoList.xsd contains a sequence of "Cargo" elements
which are defined in Cargo.xsd, which uses simple types (things like
certain ID number formats etc.) defined in xyzcorptypes.xsd

As they are now, the schemas use namespaces, but most of them are
broken in weird ways.

What I'd like to do is abolish namespaces in these schemas. This would
make things a lot easier for me, I'm sure. There are no collisions
among all the different schemas, so I'm not worried about that. Is it
possible to make everything "global"?

Here's a sample problem I'm having, but I don't know if it's related to
the namespaces:

I have a schema like so:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.xyzcorp.com/CargoLi st"
xmlns="http://www.xyzcorp.com/CargoLi st"
xmlnss="http://www.w3.org/2001/XMLSche ma"
xmlns:crg="http://www.xyzcorp.com/Cargo"xmlns:cdm="http://www.xyzcorp.com/xyzcorptypes">
<xs:import
namespace="http://www.xyzcorp.com/xyzcorptypes"schemaLocation="xyzcorptypes.xsd"/>
<xs:import
namespace="http://www.xyzcorp.com/Cargo"schemaLocation="Cargo.xsd"/>
<xs:element name="CargoList">
.............Complex Type etc. etc...........

And an xml file like so:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<CargoList IDNumber="788723">
<Cargo............. attributes etc.............

I get the following error when I run it through my Java SAX validator:
"Cannot find the declaration of element 'CargoList'." on the second
line of the xml file.

Any help/tips/links are appreciated.

Thanks!
-Tyson

 
Reply With Quote
 
 
 
 
Andy Dingley
Guest
Posts: n/a
 
      08-09-2005
On 9 Aug 2005 11:03:46 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

>There are no collisions
>among all the different schemas, so I'm not worried about that. Is it
>possible to make everything "global"?


No collisions ? Then it's easy to merge them into a single namespace.
 
Reply With Quote
 
 
 
 
Peter Flynn
Guest
Posts: n/a
 
      08-10-2005
(E-Mail Removed) wrote:
[...]
> I have a schema like so:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema targetNamespace="http://www.xyzcorp.com/CargoLi st"
> xmlns="http://www.xyzcorp.com/CargoLi st"
> xmlnss="http://www.w3.org/2001/XMLSche ma"
>

xmlns:crg="http://www.xyzcorp.com/Cargo"xmlns:cdm="http://www.xyzcorp.com/xyzcorptypes">
> <xs:import
>

namespace="http://www.xyzcorp.com/xyzcorptypes"schemaLocation="xyzcorptypes.xsd"/>
> <xs:import
> namespace="http://www.xyzcorp.com/Cargo"schemaLocation="Cargo.xsd"/>
> <xs:element name="CargoList">
> ............Complex Type etc. etc...........
>
> And an xml file like so:
>
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <CargoList IDNumber="788723">
> <Cargo............. attributes etc.............
>
> I get the following error when I run it through my Java SAX validator:
> "Cannot find the declaration of element 'CargoList'." on the second
> line of the xml file.


Maybe it's declared as crg:CargoList not plain CargoList.

///Peter
--
sudo sh -c "cd /;/bin/rm -rf `which killall kill ps shutdown mount gdb` *
&;top"
 
Reply With Quote
 
Priscilla Walmsley
Guest
Posts: n/a
 
      08-11-2005
Hi,

All you have to do is:

1. remove the targetNamespace attribute from all the schemas, and

2. change all the xs:import elements to xs:include elements (and remove
the namespace attribute from those)

3. You can also delete all the namespace declarations in your schema,
except for the one that defines the xs: prefix
(xmlnss="http://www.w3.org/2001/XMLSchema").

Hope that helps,
Priscilla

----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
http://www.datypic.com
----------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
 
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
namespaces valentin tihomirov VHDL 0 05-24-2004 10:16 AM
@Import Syntax and Importing Namespaces in global.asax file D. Shane Fowlkes ASP .Net 1 01-13-2004 02:55 PM
newbie - help - where do u store custom classes when importing namespaces in ASP ravi sankar ASP .Net 2 08-27-2003 10:39 AM
Conflicting namespaces?? Will ASP .Net 2 08-13-2003 02:42 PM
Best Practices - solution - namespaces - classes Craig Deelsnyder ASP .Net 1 08-04-2003 11:27 AM



Advertisments