Hello all!
I need to build an XML file structure so a client can import data to
one of our systems. Totally new to XML, I learned about Namespaces and
DTD, and built a nice spec using them. Now I am trying to use XML
Schemas to tell more about what kind of data are allowed on each
element/attribute, but I can't understand how to mix Namespaces and
Schemas.
Can anyone give me tips, starting points, about how to specify the
Schema for the following example XML?
<library xmlns:book="boo k" xmlns:author="a uthor">
<book:book>
<book:title>Exa mple</book:title>
<book:pages>150 </book:pages>
</book:book>
<author:autho r>
<author:title>M r</author:title>
<author:name>Ju lio Nobrega</author:name>
</author:author>
</library>
I want to say that the <title> tag has different validation rules
depending on the namespace...
Thank you!
--
Julio Nobrega http://www.inerciasensorial.com.br 6 1472
You are mis-using namespaces. Namespaces should only really be used
when you are addressing xml from different sources, say, from two
different departments, and want to keep their definitions distinct. As
someone who is producing an entire xml document, one should never use
more than one namespace. When you are aggregating documents from
different sources and are concerned about namespace clashed, you then
think about using a set of namespaces.
Here are my rules for the use of namespaces:
Rule 1 of namespace: Don't
Rule 2 of namespaces: Not yet
Rule 3 of namespaces: only when you need to
Thus your xml would look like:
<library>
<book>
<title>here</title>
<author>there </author>
</book>
<author>
<title>here</title>
<name>there</name>
</author>
</library>
xml Schema is nice because it allows you to define structure that may
be called the same, but is used in different places. e.g.:
You wanted the library/book/title element to have an ISBN attribute,
but the library/book/title element to have a number attribute (i.e.
this is the author's Nth book). Any good schema reference will tell
you how to define children element of the same name but of different
(complex/simple) types.
In conclusion, that the title element is a child of the book element
implies that it is a "book title", there's no need to define different
namespaces.
take a look at http://builder.com.com/5100-6389-1046618.html for more
on namespaces.
In article <11************ **********@g44g 2000cwa.googleg roups.com>,
<in****@gmail.c om> wrote: <library xmlns:book="boo k" xmlns:author="a uthor">
Namespace names are supposed to be absolute URLs.
-- Richard
Actually, namespaces are designated as URI's not URL's. Taken from the W3C's recommendation on XML namepsaces: <http://www.w3.org/TR/REC-xml-names/#ns-decl>
[Definition:] The attribute's value, a URI reference, is the namespace name identifying the namespace. The namespace name, to serve its intended purpose, should have the characteristics of uniqueness and persistence. It is not a goal that it be directly usable for retrieval of a schema (if any exists). An example of a syntax that is designed with these goals in mind is that for Uniform Resource Names [RFC2141]. However, it should be noted that ordinary URLs can be managed in such a way as to achieve these same goals.
In other words, the namespace URI has to be unique and that's it. URL's, by definition, are unique (all URL's are URI's but not vice versa) therefore, acceptable as namespace names. Generally, one simply uses a URL for the namespace name, however, this URL doesn't need to point to any actual document. Convention and general usefullness suggests placing the schema or DTD of said namespace at said URL is a good idea, and I concur.
nntp://news.cis.ohio-state.edu/comp.text.xml/<di***********@ pc-news.cogsci.ed. ac.uk>
In article <11************ **********@g44g 2000cwa.googleg roups.com>,
<in****@gmail.c om> wrote: <library xmlns:book="boo k" xmlns:author="a uthor">
Namespace names are supposed to be absolute URLs.
-- Richard
[comp.text.xml]
In article <di**********@n ews.cis.ohio-state.edu>,
Jason Karns <karns.17@n!o!s !p!a!m.osu.edu> wrote: Actually, namespaces are designated as URI's not URL's.
I know that. I was trying not to obscure the point with subtleties.
-- Richard
The W3C XML Schema Primer [1] has a very good introduction to this
topic which I think you will find helpful.
ht
[1] http://www.w3.org/TR/xmlschema-0/
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Chris wrote: You are mis-using namespaces. Namespaces should only really be used when you are addressing xml from different sources, say, from two different departments, and want to keep their definitions distinct.
Thank you Chris. I solved the problem by not using namespaces on my
own created file :)
Actually, I gave up on XML Schema and started using RELAX NG, but
that's another topic... not that I know how to use namespaces on RELAX
NG either, but following your advice I am not even looking how to do
it, for now :) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dominique |
last post by:
Hi all,
I am trying to create a schema (conf.xsd) that includes 2 other
schemas (a.xsd, b.xsd). in my xml file, I have namespaces for each of
these schemas, but my XML file doesn't validate... It's definitely a
grammar problem.
I have spent quite a bit of time playing with it, and can't find
related examples on the net, anyone has experience with this?
here are my example files:
|
by: tysontate |
last post by:
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...
|
by: Oisin Grehan |
last post by:
Hi,
I can't for the life of me get this to work properly. I've searched for
examples, but none of the examples quite match my environment. Here is my
XML (please treat this as immutable -- no solutions involving altering the
XML are good for me):
---- config.xml ----
|
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 against
the extra namespaces?
|
by: Mike Morse |
last post by:
What see sample that show xs:element where the xs namespace =
http://www.w3.org/2001/XMLSchema
However, I see another example with xsi: where xsi =
http://www.w3.org/2001/XMLSchema-instance
What's the difference here? Are there right and wrong namespaces? Is there
a global list of the ones to use? Does the namespace even need to point at
http://www.w3.org.....? Or is this just the accepted way?
| |
by: Michael Jackson |
last post by:
I have attempted to mark up a service and it's methods so that it
doesn't require the SOAPAction HTTP header to resolve the methods
being called, this is done from first element in <SOAP-ENV:Body> and
the request and responses are not suffixed with Request and Response.
Is there some more I could do with the attributes on the class that
defines the WS and on the methods. the code for the WS etc is below.
This I can get to work
POST...
|
by: wolf_y |
last post by:
I'm a newbie to XML and primarily program in SAS, so even though I've
consulted documentation, I can't translate into language I understand.
I hope I can explain the problem clearly.
The project I'm currently on starts with XML files (say, 10 as an
example) that, after validation, are reconfigured via SAS for Teradata
loading. Since we're in development, the location of needed schemas
isn't fixed, often moving as phases are completed...
|
by: blat001 |
last post by:
Hi,
Not 100% sure if this is the correct group to post in but.
I have a class that I want to serialize/deserialize to match the MM7
specifications, which I have done but now that we are starting to
connect to a few different people we have realised that there are
multiple versions of the specification and each one has been defined
in a different namespace, now the actual xml is the same between the
versions
|
by: theonlydavewilliams |
last post by:
Hi there
I'm hoping there's an easy answer to a (hopefully) not too long-winded issue...
I'm building a C# web client using a proxy wsdl.exe'd from a wsdl file and six schemas, each in a different namespace. Some schemas extend complex types in others. When i get a soap:Fault from my test server it could contain a serialized exception object (called fault) from one of two of these schemas (and different namespaces, call them xmlns:b0="ns1" and...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |