Invenzzia » Resources / Articles / Managing XML in OPT / XML requirements

1. XML requirements

Let's begin with a short repetition of an XML standard. This list should be in your head all the time, because many problems of the beginning OPT users are caused by forgetting they work with XML and importing solutions from other template engines that would never work here.

  1. Every XML tag must be closed. If our template contains an opening <div>, we must close it in the same template and in the same file: </div>.

  2. An XML document may contain one main tag and no more. Below we can see an example of invalid code:

    <?xml version="1.0" ?>
    <content>
      some content here
    </content>
    <content>
      error, the document cannot have another main tag!
    </content>

    To fix this file, we must pack everything with one more tag.

  3. The tag may contain the name and the attributes name="value". No other content is allowed. Every attribute must have a value defined.

  4. A document should have a prolog and DTD block (Document Type Definition).

  5. Special symbols like < or & must be encoded with entities.

XML does not put any limitations on the attribute value form and the meaning of the text between the tags. It depends on the concrete language needs and OPT makes use of this fact.