27354Custom Namespace Extension (was Re: namespace question)
- Mar 12, 2003Thanks for the quick reply, Tobi. That particular animation is one of the
earliest I'd seen of SVG (lo, these many years ago), and I found it fun and
However, this is somewhat different than what I'm doing. You are using a
predefined NameSpace, RDF, and limiting your meta-data to an isolated
section of the SVG. What I wish to do is create a custom NS, and apply it to
pre-existing SVG elements interspersed thoughout the document:
<line id="line_1_2" x1="0" y1="3" x2="15" y2="50" mcns:category="5"/>
<text id="text_5" x="10" y="50" mcns:association="line_1_2">Sample</text>
I have around 15 of these custom Attributes (so far), and no custom
Elements (yet); each can be applied to any of the following Elements:
<text>, <line>, and <use> (possibly more, as development continues).
My primary references at this point are:
W3 School DTD Tutorial
SVG1.1 Spec, section 23.5 "Adding private elements and attributes to the
My questions are:
1) Do I have to declare an ENTITY for each Attribute, for each Element? Or
can I group them together in one generic ENTITY? DO I need an ENTITY at all,
if I only have Attributes and no Elements?
2) Do I have to make a seperate ATTLIST for each Attribute, for each
Element? Or can I declare each Attribute once, and refer to that definition
in the ENTITY(s)? Does each Attribute have to have its own ATTLIST, or do I
list all the Attributes under one ATTLIST?
3) How do I determine whether I should use CDATA or PCDATA; that is, when do
I want to parse the Attribute value? Some of my Attribute values are
enumerated [(left|right|top|bottom)], but some can take values defined by
the user at runtime. Presumably the former would use PCDATA, and the latter
CDATA? if the user-defined ones are constrained in their format to use the
same alphanum charset as XML IDs, are they parsed? Conversely, are there any
restictions on non-parsed Attribute values to which I would need to
4) None of these Attributes currently affect how the SVG is rendered; they
are meta-information for use in assigning tooltip labels, establishing
complex relationships between elements (IDREF and IDREFS), and tokens for
indicating how the code should treat each Element. Is there any way I can I
use these Attributes as style classifiers, say? So that, for example, all
lines of 'mcns:category="5"' would be red, and all of category 3 would be
green? And if this can't be done in ASV3, is it at least theoretically
possible? This question is not really a high priority, but it would be neat.
5) Currently, I'm designing for ASV3/IE6, which is pretty forgiving of my
using a custom NameSpace, in terms of getting and setting Attributes. But
are there considerations to other renderers I should be aware of? Obviously,
I'm using g/setAttributeNS exclusively, now. I'd hate to build this app only
to have it end up a one-trick pony.
I must confess, this is peripheral to the application, and I wish only to
know as much as I need to in order to make my SVG valid, so I don't really
want to read a book on the subject. A pointer to an online tutorial or an
example would be great.
Sorry for the long and possibly OT post.
Tobias Reif wrote:
> > I've also been embedding "meta-information" in one of my SVG
> apps, in much
> > the way that Jon has, below. [...] But now I want to define
> > the namespace attributes, to make it "legal" and valid, if possible.
> Check the source of
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.458 / Virus Database: 257 - Release Date: 2/24/2003
- << Previous post in topic