0

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.

potame
  • 7,597
  • 4
  • 26
  • 33

2 Answers2

1

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.

jelovirt
  • 5,844
  • 8
  • 38
  • 49
  • Thank!..i am getting some complication in figure and table constraints. In figure and table several othere elements are there. do i need to declare all elements and entity in constraints? – user3165851 Mar 26 '14 at 06:41
  • Yes, you need to add the elements you want into `fig` and `table`, there is no shortcut to just make them mandatory. – jelovirt Mar 27 '14 at 17:28
0

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) >
PhillyNJ
  • 3,859
  • 4
  • 38
  • 64