non-deterministic content model error DTD

251 Views Asked by At

Given:

<!ELEMENT diagnostic-tracks (hookup*, (%step;)*, ((diagnostic-track-automated, diagnostic-track-manual) | diagnostic-track-automated | diagnostic-track-manual), evaluate*, disconnect*)>

and

<!ELEMENT diagnostic-track-automated (((%step;) | diagnostic_group)*, diagnostic_group, evaluate*)>

<!ENTITY % step "((%figtab;) | step1 | step1-alt)">
<!ENTITY % figtab "figure | figure-alt | table | table-alt | lubetab">

I am getting non-deterministic content model errors that diagnostic-track-automated and diagnostic_group could simultaneously match two or more tokens.

I changed to:

<!ELEMENT diagnostic-tracks (hookup*, (%step;)*, diagnostic-track-automated?, diagnostic-track-manual?, evaluate*, disconnect*)>

and

<!ELEMENT diagnostic-track-automated (((%step;) | diagnostic_group+)*, evaluate*)>

which eliminated the error messages, but I don't think my changes, especially for diagnostic-track-automated, are correct.

I appreciate any suggestions for improvement.

1

There are 1 best solutions below

6
Daniel Haley On BEST ANSWER

I think what you came up with for diagnostic-tracks appears to be what you were trying to accomplish with the original non-deterministic model:

zero or more hookup elements followed by
zero or more elements from %step; followed by
zero or one diagnostic-track-automated element followed by
zero or one diagnostic-track-manual element followed by
zero or more disconnect elements

However I think the fix for diagnostic-track-automated is not what you originally intended.

What you propose now is:

zero or more elements from %step; or diagnostic_group followed by
zero or more evaluate elements

What I think you meant was:

zero or more elements from %step; followed by
one or more diagnostic_group elements followed by
zero or more evaluate elements

Which would be:

<!ELEMENT diagnostic-track-automated ((%step;)*, diagnostic_group+, evaluate*)>

Here's a full/testable example...

DTD (so.dtd)

<!ENTITY % figtab "figure | figure-alt | table | table-alt | lubetab">
<!ENTITY % step "%figtab; | step1 | step1-alt">

<!ELEMENT diagnostic-tracks (hookup*, (%step;)*, diagnostic-track-automated?, diagnostic-track-manual?, evaluate*, disconnect*)>

<!ELEMENT diagnostic-track-automated ((%step;)*, diagnostic_group+, evaluate*)>

<!ELEMENT table EMPTY>
<!ELEMENT table-alt EMPTY>
<!ELEMENT diagnostic_group EMPTY>
<!ELEMENT step1-alt EMPTY>
<!ELEMENT evaluate EMPTY>
<!ELEMENT figure EMPTY>
<!ELEMENT figure-alt EMPTY>
<!ELEMENT lubetab EMPTY>
<!ELEMENT step1 EMPTY>
<!ELEMENT diagnostic-track-manual EMPTY>
<!ELEMENT disconnect EMPTY>
<!ELEMENT hookup EMPTY>

XML

<!DOCTYPE diagnostic-tracks SYSTEM "so.dtd">
<diagnostic-tracks>
    <diagnostic-track-automated>
        <diagnostic_group/>
    </diagnostic-track-automated>
    <diagnostic-track-manual/>
</diagnostic-tracks>