[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [xml-dev] Should attributes be prefixed
Uh oh, here we go again.
I like to follow the convention that XSLT uses: when attributes are "owned"
by the element, don't put it in a namespace. It's already sufficiently
scoped by the owner element.
<xsl:element name="foo" use-attribute-sets="bar"/>
But when you want to use an attribute on "someone else"'s element, i.e. in a
different namespace (for example, in XSLT, on a literal result element),
then put your attribute in your namespace so as to distinguish it from an
attribute owned by that element.
<myElement myAttribute="lala" xsl:use-attribute-sets="bar"/>
The upshot is that attributes aren't usually in a namespace, except in
special cases like these.
This isn't the only approach. (See subsequent flames.)
From: Doug Ransom [mailto:Doug.Ransom@pwrm.com]
Sent: Tuesday, November 20, 2001 1:17 PM
To: Xml-Dev@Lists. Xml. Org (E-mail)
Subject: [xml-dev] Should attributes be prefixed
When should attributes be prefixed and included in a namespace, and when
should attributes reside globally.
i.e. global attribute <V units="Volts" xmlns="mailto:Doug.Ransom@pwrm.com"/>
vs attribute in the namespace
<p:V p:units="Volts" xmlns:p="mailto:Doug.Ransom@pwrm.com"/>
In both cases, the units value must exist within the V element for the
element to be valid.
Software Engineer/Internet Technologies Domain Lead
tel:250-652-7100 x 7558
Request My VCard