Pregunta

I have this code:

<!ENTITY % id "id ID #IMPLIED">
<!ENTITY % comment "comment CDATA #REQUIRED">

...

<!ELEMENT methodology (#PCDATA)>
<!ATTLIST methodology %id;>

<!ELEMENT updated (#PCDATA)>
<!ATTLIST info %comment;>

Why for the comment the name of the info ATTLIST is different of his ELEMENT name? And I don't know if in XML I have this code for element updated:

<updated comment="This is a comment">
DATE
</updated>
¿Fue útil?

Solución

According to your DTD, you <updated> may not have a comment attribute (unless it's declared in the parts that you omitted.)

The info ATTLIST is the list of attributes for the <info> element. The syntax for ATTLIST is:

<!ATTLIST element-name attribute-name attribute-type default-declaration>

The declaration for the <info> element in your DTD is:

<!ATTLIST info comment CDATA #REQUIRED>

%comment; is a reference to the parameter entity which was declared in the beginning of the file Parameter entities are useful if you need to reuse bits of code many times. Your %comment; entity defines a string which is a part of the ATTLIST declaration. Perhaps the %comment; parameter entity is used a lot in your code because all or many elements have a comment attribute, so you could avoid retyping it many times using the entity. If updated has a comment attribute it might be defined as:

<!ATTLIST updated %comment;>

But it would be perfectly valid to not use the entity as well:

<!ATTLIST updated comment CDATA #REQUIRED>

Your %id; entity has the same purpose. The attribute list for <methodology> could also have been declared without the entity as:

<!ATTLIST methodology id ID #IMPLIED>

You can read more about parameter entities. They aren't hard to understand. Check this tutorial: http://www.ibm.com/developerworks/library/x-tiparam/

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top