Search code examples
dtdtei

A .dtd show constant error, while the line seems okey when inserted into another file


I compiled a .dtd for my recent project, but a line shows constant error:

<!ELEMENT front ((%model.frontPart;|%model.pLike;|%model.pLike.front;|%model.global;)*,(((_DUMMY_model.div1Like,(_DUMMY_model.div1Like|%model.frontPart;|%model.global;)*)|(%model.divLike;,(%model.divLike;|%model.frontPart;|%model.global;)*)),((%model.divBottom;),(%model.divBottom;|%model.global;)*)?)?)>

It says I missed an ')' from this line, while if I insert this code another .dtd, everything is alright. I don't know if you guys know how to help me, but I really appreciate if you try.


Solution

  • It's most likely one or more parameter entities aren't declared in your DTD.

    The reason I believe this is if I take the element declaration in your question and strip out all of the % and ; to make those parameter entity references element names, and I create element declarations for them (just for testing), I don't get any validation errors (used Xerces for testing). This rules out an issue with parens.

    For example, your DTD has %model.frontPart;. Your DTD would also need to have a declaration like:

    <!ENTITY % model.frontPart "foo">
    

    With foo being whatever the entity value is.

    There needs to be an entity declaration for all of the parameter entity references in your example:

    %model.divBottom;
    %model.divLike;
    %model.frontPart;
    %model.global;
    %model.pLike.front;
    %model.pLike;
    

    Compare the DTD you get the error in against the DTD you don't get the error in; does one have all of the entity declarations while one doesn't?

    If this is not the case, please update your question with more information. (The entire DTD would be ideal.)