473,802 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Namespaces & prefixed attributes (one more time)

kj


In an earlier thread, JKrugman posted the following quote:
...the purpose of XML namespaces is to uniquely identify element
and attribute names. Unprefixed attribute names can be uniquely
identified based on the element type to which they belong, so
there is no need identify them further by including them in an
XML namespace. In fact, the only reason for allowing attribute
names to be prefixed is so that attributes defined in one XML
language can be used in another XML language. (from http://www.rpbourret.com/xml/NamespacesFAQ.htm#q5_3)

This quote suggests that, when designing a schema/DTD one can safely
let most (if not all) attributes have no namespace (i.e. be
"unprefixed "); during this design phase, only rarely need one
specify an attribute as belonging to a namespace (i.e. requiring
a prefix).

But I am interested in learning to recognize those rare situations
in which, as a designer, one *should* put a particular attribute
in a namespace. This is still very unclear to me. What are the
requirements that an attribute must fulfill to be a good candidate
for being placed in a namespace?

Thanks!

kj
--
NOTE: In my address everything before the period is backwards.
Jul 20 '05 #1
2 1421
kj wrote:

But I am interested in learning to recognize those rare situations
in which, as a designer, one *should* put a particular attribute
in a namespace. This is still very unclear to me. What are the
requirements that an attribute must fulfill to be a good candidate
for being placed in a namespace?


The one which comes to mind is where the attribute belongs to a
different namespace than that of the sorrounding element. This is
relevant e.g. when specifying that the "id" attribute should have the
properties of the special XML Schema "id" attribute (it has to be unique
in all the XML document):
<html:table title="Jack's finest recipies" xsd:id="recipie s">
The "title" attribute doesn't need a namespace, because it is inferred
from the sorrounding element. The "id" attribute in this case does not
belong to the html namespace. Using xsd:id can be useful for validation
purposes.

--
Victor
Jul 20 '05 #2
Victor Engmark <vi************ @cern.ch> writes:
kj wrote:
... What are the
requirements that an attribute must fulfill to be a good
candidate for being placed in a namespace?
The one which comes to mind is where the attribute belongs
to a different namespace than that of the sorrounding element.
This is true.
This is relevant e.g. when specifying that the "id" attribute
should have the properties of the special XML Schema "id"
attribute (it has to be unique in all the XML document): <html:table title="Jack's finest recipies" xsd:id="recipie s">


Er, I'm not sure this is right. The XML Schema namespace does not
define a top-level attribute named 'id'. It defines a top-level
simple type named ID (or xsd:ID, if you've bound the 'xsd' prefix to
"http://www.w3.org/2001/XMLSchema"), which requires its value to be
unique among the values of that type occurring in a document, just
like the ID attribute type of DTDs. But no top-level attribute.

There are occasional proposals for an xml:id attribute which would be
declared as having type xsd:ID -- indeed, the W3C XML Core Working
Group published a Working Draft proposing such an attribute just the
other day (http://www.w3.org/TR/2004/WD-xml-id-20040407/). If you
changed 'xsd:id' to 'xml:id' in the example above I think the usage
shown would be correct.
On the original question, one answer is simple: it makes sense to
define a top-level attribute when you can say what the attribute means
without any reference to the meaning or type of the element it appears
on. An attribute like 'xml:id' qualifies because its meaning
('provides an identifier which uniquely identifies the host element
within the document') can be described without any reference to the
name, type, or meaning of the host element.

I hope this helps.

-C. M. Sperberg-McQueen
World Wide Web Consortium
Jul 20 '05 #3

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

Similar topics

18
3054
by: Steven Bethard | last post by:
In the "empty classes as c structs?" thread, we've been talking in some detail about my proposed "generic objects" PEP. Based on a number of suggestions, I'm thinking more and more that instead of a single collections type, I should be proposing a new "namespaces" module instead. Some of my reasons: (1) Namespace is feeling less and less like a collection to me. Even though it's still intended as a data-only structure, the use cases...
5
4399
by: Steve Jorgensen | last post by:
I was having a bear of a time today trying to figure out some inconsistent behavior selecting nodes from and MSXML DOM document, so I distilled the issue down to a trivial test demonstrating the confusing behavior. The deal is that I want to create most of my XML nodes from code using createNode, but the code is much more clear if I can start by building the basic skeleton of the document using a simple XML string. The catch is, I'll...
0
2296
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...
36
4056
by: Wilfredo Sánchez Vega | last post by:
I'm having some issues around namespace handling with XML: >>> document = xml.dom.minidom.Document() >>> element = document.createElementNS("DAV:", "href") >>> document.appendChild(element) <DOM Element: href at 0x1443e68> >>> document.toxml() '<?xml version="1.0" ?>\n<href/>' Note that the namespace wasn't emitted. If I have PyXML,
8
2819
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);" TextBox2.Attributes.Add("onKeyPress", jscode) You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as &amp;&amp; in the code that is
6
3014
by: AMDRIT | last post by:
Hello Everyone, I am having an issue with xml and namespaces, at least I think it is namespaces. When I use namespaces, I cannot use SelectSingleNode / SelectNodes as they always return 0/Nothing respectively. Anyone have any thoughts? Thanks in advance VB.Net 2005
4
1803
by: VK | last post by:
Can well-formed but non-validated XHTML have extra namespaces? Say <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head>
0
5577
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
7
1628
by: Grant Robertson | last post by:
As I am learning about XML I seen that xmlns is used with a colon after it as if it were a namespace itself. However, I have never seen a URI given for it. Is "xmlns" a sort of predefined word in that all XML software just knows what it means without it needing a URI? Are there any more of these special words that need no definition within any schema? I know there are other special words like "element" and "targetNamespace" but these...
0
9699
marktang
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...
0
9562
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,...
0
10538
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10305
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7598
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
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();...
0
5494
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...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3792
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.