Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > BOOK: Beginning XML, 4th Ed ISBN: 978-0-470-11487-2
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning XML, 4th Ed ISBN: 978-0-470-11487-2
This is the forum to discuss the Wrox book Beginning XML, 4th Edition by David Hunter, Jeff Rafter, Joe Fawcett, Eric van der Vlist, Danny Ayers, Jon Duckett, Andrew Watt, Linda McKinnon; ISBN: 9780470114872
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning XML, 4th Ed ISBN: 978-0-470-11487-2 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 10th, 2011, 12:30 PM
Registered User
 
Join Date: May 2011
Posts: 4
Thanks: 2
Thanked 0 Times in 0 Posts
Default In what namespace(s) are these attributes defined?

hi

1)

Code:
<?xml version="1.0" encoding="utf-8" ?>
<contacts xmlns:prefixA="http://localhost/URI_A" xmlns:B="http://localhost/URI_B" ... >
</contacts>
a) In what namespace is xmlns attribute defined and why don't we have to specify this namespace via schemaLocation/xmlns attributes?

b) Are xmlns:prefixA and xmlns:prefixB attributes defined in the same namespace as xmlns attribute?

c) Is the name of the attribute xmlns:prefixA or just prefixA?

2) An element is defined within an XML Schema (XSD) using <element> element. <element> can contain attributes such as name, type, ref, form, minOccurs, maxOccurs, default and fixed. In what namespace are these attributes declared?

Thank you
  #2 (permalink)  
Old May 11th, 2011, 06:21 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

My answers may not be 100% technically correct but:
(a) the xmlns namespace is built-in to XML processors so you don't have to define them yourself. I'm not sure if it has a URI associated with it but I have sometimes seen http://www.w3.org/2000/xmlns/ specified, I think this also applies to part b of your question.

It doesn't count as an attribute though, it's a way of defining namespaces in your document so the answer to (c) is neither.

For question 2 XML schemas normally use the prefix xs or xsd and this is bound to the http://www.w3.org/2001/XMLSchema URI. However attributes only usually reside in a namespace is they have a prefix, they don't assume the default namespace as elements can. So the attributes you quote don't have an associated namespace URI.
__________________
Joe
http://joe.fawcett.name/
The Following User Says Thank You to joefawcett For This Useful Post:
flockofcode (May 11th, 2011)
  #3 (permalink)  
Old May 11th, 2011, 03:55 PM
Registered User
 
Join Date: May 2011
Posts: 4
Thanks: 2
Thanked 0 Times in 0 Posts
Default

hi

I'm also learning Linq to XML and I did a bit of searching and found the following quote:

Quote:
When you declare namespaces, the namespace attributes themselves are in the xmlns namespace. The W3C standard specifies that this namespace does not have to be declared as an attribute in the XML tree. It is a reserved namespace that is always automatically available in the XML parser.
... To create an attribute that declares a namespace with a prefix, you create an attribute where the name of the attribute is the namespace prefix, and this name is in the Xmlns namespace.

Do according to the above quote only the xmlns "attributes" with prefixes ( such as xmlns:prefixA) live in Xmlns namespace, or does xmlns "attribute" itself ( thus xmlns=«...« ) also live in a Xmlns namespace?
 


Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ADODB.Connection user-defined type not defined Wall st Guru Excel VBA 2 March 26th, 2014 03:44 PM
How do we include the namespace and xsd as attributes to the tag anarleti XSLT 5 July 8th, 2010 08:14 AM
Declaring attributes for namespace declarations in DTDs. GrantRobertson BOOK: Beginning XML, 4th Ed ISBN: 978-0-470-11487-2 0 November 2nd, 2009 12:20 AM
Appl-defined or Object-defined error 1004 chp Excel VBA 3 April 4th, 2006 08:12 AM
User-defined type not defined (Icecream.mdb) dloren01 BOOK: Beginning Access VBA 0 June 22nd, 2005 10:36 PM



All times are GMT -4. The time now is 03:19 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.