Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > BOOK: Beginning XML, 4th Ed ISBN: 978-0-470-11487-2
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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
 
Old May 11th, 2011, 06:21 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
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)
 
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?





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 01: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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.