Can anyone help me create DITA DTD constraints?
I want to create Constraints for figure, image and table.
Image tag with alt tag mandatroy
I want the figure title to also be mandatory, while table title, desc, and thead with at least one entry.
Can anyone help me create DITA DTD constraints?
I want to create Constraints for figure, image and table.
Image tag with alt tag mandatroy
I want the figure title to also be mandatory, while table title, desc, and thead with at least one entry.
Create imageConstraints.mod
:
<!ENTITY altReq-constraint
"(topic altReq-c)">
<!ENTITY % image.content
"((%alt;),
(%longdescref;)?)">
Then include it into your shell DTD with something like
<!ENTITY % altReq-c-def
PUBLIC "-//FOO//ELEMENTS DITA 1.2 Required Alt Constraint//EN"
"imageConstraint.mod">
%altReq-c-def;
and add it the included-domains
entity
<!ENTITY included-domains "...
&altReq-constraints;">
Figure and table follow the same pattern.
You can't force the at least one table header entry rule with DTDs, for that you need to use e.g. Schematron.
My DTD knowledge is a bit rusty, but I believe if you are modifying the DTD and the element is optional it will have a question mark next to it
<!ELEMENT title (#PCDATA )>
<!ELEMENT figure (title?) >
To make is title
required, remove the ?
:
<!ELEMENT title (#PCDATA )>
<!ELEMENT figure (title) >