w0*****@ouray.c udenver.edu (wzhang) writes:
Hi,
I would like to add some custom elements to svg files and also some
custom attributes to certain svg elements. Should I create a DTD to
include the cumtom elements and attributes?
<!ATTLIST {element name} {attribute name} {type} {default option}>. If
I do need to create a DTD, then how do I specify the element name in
custom attributes declaration since the element itself is in SVG? For
exampe, I would like to do this: <svg mynamespace:mya ttr="something" >.
Take a look at the existing SVG dtd. The flat version is at:
http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-flat.dtd
The SVG DTD was designed specifically with extension in
mind. All you have to do is make appropriate declarations in your
internal DTD. Take, for instance, the <svg> element itself: it is defined
by:
<!ELEMENT %SVG.svg.qname; %SVG.svg.conten t; >
The %SVG.svg.qname; is "svg", along with any appropriate prefix
(which you can specify by defining %SVG.prefix;)
The actual content is specified by the %SVG.svg.conten t;. This
entity is defined to include another parameter entity,
%SVG.svg.extra. content;. This is defined blank initially, and is
available for you to specify in your internal DTD subset, e.g.:
<!ENTITY % SVG.svg.extra.c ontent "| foo">
To indicate that svg can also contain a <foo/> element.
Similarly, many of the attribute groups also allow extensions
(AFAICT, most of the elements themselves don't allow direct
attribute extension, since they mostly just use groups of shared
attributes).
For instance, to add to the Core Attributes an attribute that may
be present in any element, you define %SVG.Core.extra .attrib; :
<!ENTITY % SVG.Core.extra. attrib "foo CDATA #IMPLIED">
For more info, read the flat DTD whose link I gave earlier, and
the Extensibility section of the SVG spec:
http://www.w3.org/TR/SVG11/extend.html
HTH.
--
Micah J. Cowan
mi***@cowan.nam e