DTD question

W

wzhang

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:myattr="something">.

Thanks a lot in advance.

wz
 
M

Micah Cowan

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:myattr="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.content; >

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.content;. 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.content "| 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.
 
W

wzhang

Hi, Micah,

Thank you for your reply. I did the internal DTD. But since I am going
to use it in a lot of svg files, I would like to do it with an
external DTD. Is there a way to do it?

Thanks.

wz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top