473,382 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Abolishing Namespaces

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"
xmlns:xs="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

Aug 9 '05 #1
3 1315
On 9 Aug 2005 11:03:46 -0700, ty*******@gmail.com 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.
Aug 9 '05 #2
ty*******@gmail.com 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"
xmlns:xs="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"
Aug 10 '05 #3
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
(xmlns:xs="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 ***
Aug 11 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Steven Bethard | last post by:
In the "empty classes as c structs?" thread, we've been talking in some detail about my proposed "generic objects" PEP. Based on a number of suggestions, I'm thinking more and more that instead of...
11
by: Random | last post by:
I'm confused about the proper use and usefulness of namespaces. I beleive I understand the purpose is so the developer can put classes within namespaces to essentially organize your code. And I...
11
by: Random | last post by:
I'm confused about the proper use and usefulness of namespaces. I beleive I understand the purpose is so the developer can put classes within namespaces to essentially organize your code. And I...
22
by: Random | last post by:
I'm confused about the proper use and usefulness of namespaces. I beleive I understand the purpose is so the developer can put classes within namespaces to essentially organize your code. And I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.