XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 10th, 2013, 06:23 PM
zxcvbnm's Avatar
zxcvbnm zxcvbnm is online now
A Change of Season
Click here for more information.
 
Join Date: Mar 2004
Posts: 1,590 zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 19 h 52 m
Reputation Power: 70
About xml namespaces

I understand that "namespaces" are a way of grouping elements and attributes under a common heading in order to differentiate them from a similarily named items.

I see this on top of documents quite often use the famouse w3.org url as the namespace:
Code:
<html xmlns="http://www.w3.org/1999/xhtml">
This namespace is a web page. It does not contain any rules or definitions of the namespace So does this mean a namespace could be "anything" as long as it's a unique string? It does not have to include any rules does it? The reason I ask is that I read:
Quote:
Namespace identifier is a string of characters such as isbn, which identifies how the namespace specific string should be interpreted
How can it specify how a string should be interpreted if it is doesn't contain anything?
Thanks

Last edited by zxcvbnm : March 11th, 2013 at 12:33 AM.

Reply With Quote
  #2  
Old March 10th, 2013, 07:45 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,682 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 2 h 23 m 36 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Yes. Namespaces should be URIs (I've seen things that complain if they're not) but they don't have to be to some computer-readable specification. Human-readable is a good idea though.

As for your second question, it's too confusing, I can't tell what you're asking.

Reply With Quote
  #3  
Old March 11th, 2013, 12:35 AM
zxcvbnm's Avatar
zxcvbnm zxcvbnm is online now
A Change of Season
Click here for more information.
 
Join Date: Mar 2004
Posts: 1,590 zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 19 h 52 m
Reputation Power: 70
Quote:
Originally Posted by requinix
Yes. Namespaces should be URIs (I've seen things that complain if they're not) but they don't have to be to some computer-readable specification. Human-readable is a good idea though.

As for your second question, it's too confusing, I can't tell what you're asking.
Ok let's say it is a human readable string. How can a string contain rules or definitions? In other words, I can open a DTD and see all the rules and specifications but I don't understand how a string can contain rules!

I hope it's clear what I am asking

Reply With Quote
  #4  
Old March 11th, 2013, 12:49 AM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,682 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 2 h 23 m 36 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
It doesn't have to, that's what I'm saying. Neither the URI nor the document it's pointing to have to include rules or definitions or schema. It's more or less an arbitrary string. It is, however, a Good Thing To Do because then other people reading the XML can easily find out the schema without having to Google stuff or hunt down your documentation.

Reply With Quote
  #5  
Old March 11th, 2013, 01:05 AM
zxcvbnm's Avatar
zxcvbnm zxcvbnm is online now
A Change of Season
Click here for more information.
 
Join Date: Mar 2004
Posts: 1,590 zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 19 h 52 m
Reputation Power: 70
Quote:
Originally Posted by requinix
It doesn't have to, that's what I'm saying. Neither the URI nor the document it's pointing to have to include rules or definitions or schema. It's more or less an arbitrary string. It is, however, a Good Thing To Do because then other people reading the XML can easily find out the schema without having to Google stuff or hunt down your documentation.
I don't know if I am slow or these things are confusing for everyone!

Reply With Quote
  #6  
Old March 11th, 2013, 04:24 AM
zxcvbnm's Avatar
zxcvbnm zxcvbnm is online now
A Change of Season
Click here for more information.
 
Join Date: Mar 2004
Posts: 1,590 zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 19 h 52 m
Reputation Power: 70
Requinix;

I am not gonna open a bew thread but I am going to ask a question here

1 - What is the difference between these 2 XMLs?

2 - What happens when I want applicationUsers element to use both namespaces?

3 - Why isnt there a prefix for the default name space?

Thank you
Code:
<hr:applicationUsers xmlns="http://www.webmoosh.com/namespaces/hr/entities"
	xmlns:hr="http://www.webmoosh.com/namespaces/hr/config">
	<user  hr:firstname="Behnam" />
	<user hr:firstname="John" />
</hr:applicationUsers>
And
Code:
<applicationUsers xmlns="http://www.webmoosh.com/namespaces/hr/entities"
	xmlns:hr="http://www.webmoosh.com/namespaces/hr/config">
	<user  hr:firstname="Behnam" />
	<user hr:firstname="John" />
</applicationUsers>

Last edited by zxcvbnm : March 11th, 2013 at 04:28 AM.

Reply With Quote
  #7  
Old March 11th, 2013, 12:49 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,682 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 2 h 23 m 36 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
1. In the first the root node is in a different namespace than the <user>s below it. (In the second they're in the same one.)
2. You can't. A node or attribute can only belong in one namespace, though a node and its attributes don't all have to be in the same one (like with the <user>s).
3. Because it's easier that way?

Reply With Quote
  #8  
Old March 11th, 2013, 06:37 PM
zxcvbnm's Avatar
zxcvbnm zxcvbnm is online now
A Change of Season
Click here for more information.
 
Join Date: Mar 2004
Posts: 1,590 zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 19 h 52 m
Reputation Power: 70
Thanks Requinix;

Is this valid? The reason I ask is that:

1 - There is no default name space. Both name spaces have prefix! Is it ok not to have a default name space?

2 - ApplicationUsers element does not have any namespace. Is it ok?

3 - Elements and attributes each have a seperate namespace assigned to them. For example the dial attributes under phone element has a different name space than phone element, still valid?

Code:
<applicationUsers xmlns:tr="http://www.webmoosh.com/namespaces/hr/entities"
	xmlns:hr="http://www.webmoosh.com/namespaces/hr/config">
	<user  hr:firstname="Behnam" />
	<address unit="5" />
        <tr:phone hr:dial="5544098" />
</applicationUsers>

Reply With Quote
  #9  
Old March 11th, 2013, 06:59 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,682 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 2 h 23 m 36 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
1. The default namespace always exists; if you don't define it yourself you get the default xmlns="". In your example <applicationUsers>, <user>, and <address> are in the default namespace.
2. Yes (see above) but I don't think that's what you want.
3. Yes.

Reply With Quote
  #10  
Old March 13th, 2013, 05:06 PM
zxcvbnm's Avatar
zxcvbnm zxcvbnm is online now
A Change of Season
Click here for more information.
 
Join Date: Mar 2004
Posts: 1,590 zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level)zxcvbnm User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 19 h 52 m
Reputation Power: 70
Requinx:
This is an over simplified xml:
Code:
<?xml version="1.0"?>
<note
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com note.xsd">
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>
And this is the Schema:
Code:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">

<xs:element name="note">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="to" type="xs:string"/>
      <xs:element name="from" type="xs:string"/>
      <xs:element name="heading" type="xs:string"/>
      <xs:element name="body" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

</xs:schema>
1 - Why does the schema need name spaces? It makes sense that the xml simply looks at the schema without need to the namespaces in the schema. Would you please clarify why there is a need for name spaces in the schema itself?

2 - The <note> element could be anything right? For example <root>?

3 - Why defining xsi name space when it is not used in the xml at all?

4 - This schema is NOT a URI, right? Cause URI is a unique string which could not even exist. This schem (which is a namespace) is more than just a string. Clarify please.

Thanks

Last edited by zxcvbnm : March 13th, 2013 at 05:24 PM.

Reply With Quote
  #11  
Old March 13th, 2013, 06:56 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,682 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 2 h 23 m 36 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
1. The schema needs the namespace corresponding to XML Schema itself, otherwise it's just plain XML.

2. Depends. In this case no because the associated schema only defines a "note" element. It also depends on what's reading the XML back and the purposes of the XML. Logically speaking the root could have been named anything but technically speaking the writers chose that name so that's what you have to use.

3. It does use it: the schemaLocation.

4. You mean the namespace? It certainly is a URI. The schemaLocation? That maps a namespace URI to an actual document (XML Schema) that can be used to validate the XML. So if a parser wanted to validate the XML it would load the "note.xsd" file and use it to validate stuff under the "http://www.w3schools.com" namespace.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > About xml namespaces

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap