473,513 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DTDs, schema's and namespaces

Hi,

I've got a problem validating an xml document with both a dtd and
a schema. The problem seems to be about namespaces. What I want is a
well-formed, valid XML document, which also validates against a schema.
The following document validates ok at
http://www.stg.brown.edu/service/xmlvalid/ which doesn't check the schema.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<!DOCTYPE minim SYSTEM "http://www.cs.vu.nl/~embronne/XML/minim/minim.dtd">

<minim xmlns="http://www.cs.vu.nl/~embronne/XML/minim"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.cs.vu.nl/~embronne/XML/minim http://www.cs.vu.nl/~embronne/XML/minim/minim.xsd">

<lmnt>
Only one.
</lmnt>

</minim>

However, the xsv schema validator (http://www.w3.org/2001/03/webdata/xsv)
complains that: "element {http://www.cs.vu.nl/~embronne/XML/minim}:lmnt
not allowed here (1) in element
{http://www.cs.vu.nl/~embronne/XML/minim}:minim, expecting [{None}:lmnt]".
This can be fixed as follows:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<!DOCTYPE minim SYSTEM "http://www.cs.vu.nl/~embronne/XML/minim/minim.dtd">

<mnm:minim xmlns:mnm="http://www.cs.vu.nl/~embronne/XML/minim"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.cs.vu.nl/~embronne/XML/minim http://www.cs.vu.nl/~embronne/XML/minim/minim.xsd">

<lmnt>
Only one.
</lmnt>

</mnm:minim>

This seems to be unacceptable to the dtd-validator. If I want this to work
I'd have to modify the dtd and make "mnm:minim" the root element and add as
an attribute "xmlns:mnm". This I find an ugly solution. I was already
dissatisfied that I had to declare "xmlns:xsi" and "xsi:schemaLocation" as
attributes, but making "mnm:minim" the root element, while it should be
"minim" which just happens to be in the namespace "mnm" is really horrible.
Are there better solutions?

Regards, Miel.
Jul 20 '05 #1
2 1529
In article <bl*********@star.cs.vu.nl>,
Miel Bronneberg <em******@cs.vu.nl> wrote:
<minim xmlns="http://www.cs.vu.nl/~embronne/XML/minim"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.cs.vu.nl/~embronne/XML/minim
http://www.cs.vu.nl/~embronne/XML/minim/minim.xsd">

<lmnt>
Only one.
</lmnt>

</minim>


Ok, so you want minim and lmnt to both be in the minim namespace, which
is very reasonable.

But your schema (I just downloaded it) is

<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.cs.vu.nl/~embronne/XML/minim"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:mnm="http://www.cs.vu.nl/~embronne/XML/minim">

<element name="minim" type="mnm:minimType"/>

<complexType name="minimType">
<sequence>
<element name="lmnt" type="string" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>

</schema>

This declares the local lmnt element in *no namespace*, not in the
minim namespace. Add elementFormDefault="qualified" to the schema
element.

-- Richard
--
Spam filter: to mail me from a .com/.net site, put my surname in the headers.

FreeBSD rules!
Jul 20 '05 #2
Richard Tobin <ri*****@cogsci.ed.ac.uk> wrote:
: In article <bl*********@star.cs.vu.nl>,
: Miel Bronneberg <em******@cs.vu.nl> wrote:

[snip]

: Ok, so you want minim and lmnt to both be in the minim namespace, which
: is very reasonable.

: But your schema (I just downloaded it) is

[snip]

: This declares the local lmnt element in *no namespace*, not in the
: minim namespace. Add elementFormDefault="qualified" to the schema
: element.

Ok, thanks, that works. Now that you mention it, I have read about this
somewhere. Apologies for not reading the manual well enough.

Thanks, Miel.

--
I'm sorry if my messages are a bit short and perhaps seem somewhat
impolite. Terrible pains in my right arm prevent me from writing longer,
more courteous messages.
Jul 20 '05 #3

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

Similar topics

5
2150
by: Brandons of mass destruction | last post by:
Ok, I work for a small newspaper thats looking to translate our content to the web. XML sounds like a good way to do this, but i'm a little confused. Is it possible to have <b> and <i> tags in an XML document? we'd need to do this editorial style (movie names get are italic etc) When writing a dtd for the paper, it seems as though...
5
2222
by: Zombie | last post by:
Hi, Can I have 2 namespaces in the same XML schema? In the schema, I wish to declare elements such that some of them belong to one namespace and others belong to a second namespace. Is this possible? Note that both the namespaces should be in the same schema and same xsd file. Could somebody provide a small snippet on how to do this? ...
4
3530
by: Ian | last post by:
I would like to set a path to a schema where both the xml file and the schema are on my local hard drive (e.g. c:\XML\auto.xml and c:\XML\auto.xsd) Thank you, Ian
2
2471
by: Stanimir Stamenkov | last post by:
I'm trying to find out if it is permissible to include a schema document with absent target namespace to a schema with specified target namespace, and if it is, what are the rules to resolve the target namespace of the components from the included schema document. I'm confused because of the rules I read in the XML Schema spec...
1
1818
by: Ryan | last post by:
I have a very complex XDR schema that uses namespaces: xmlns="urn:schemas-microsoft-com:xml-data" xmlns:b="urn:schemas-microsoft-com:BizTalkServer" xmlns:d="urn:schemas-microsoft-com:datatypes" Do I need to build a custom validator in order to validate XML documents against this schema? How does the XML parser know how to validate...
6
2561
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a schema for it with Visual Studio, I get the error "Failed to create a schema for this data file because:
2
6899
by: PeterW | last post by:
I have an xml file from which I want to generate an xsd schema and at a later stage a cs class. The xml file has a mix of defined namespaces and also an empty namespace. These are defined as follows: <silcn:silcn xmlns:silcn='http://silcn.org/200309' xmlns='http://xmlprobe.com/200312'> it contains an element <report> off the root and...
6
4420
by: LesleyW | last post by:
Hi Apologies if this is a really dumb question, but being new to XML and Schemas, I wonder if giving the namespace for eg xsd or xsi as a website address means that the user has to be online when they run the app? If so, what should I do if I can't guarantee that they will be? Can I bring all these files into the app? Is that desirable? ...
9
3124
by: wardy1975 | last post by:
Hi All, Looking for a little expert advice on a few web standards issues. I am currently trying to understand the impact of web standards for a web application I work with. I have been doing a lot of research in the areas of XHTML and WAI compliance, and am attempting to come up with a recommendation for our product in terms of standards...
0
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7565
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5704
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5103
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4759
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.