Using XML: A PHP Developer's Primer, Part 6: Validation. Providing Options in RELAX NG. Providing Options in RELAX NG(Page 1 of 4 ) Giving the user choices In the last article, we created a schema requiring a root element named people that represents a list of people, with child elements named person to represent the individual people in the list. These are reasonable constraints, and we'll continue modifying the schema using the exact same scenario. We also created an attribute of the person element named date, which represents the date on which the person was added to the list.
Making an attribute optional in RELAX NG is easy. In the compact schema, this is done by inserting a question mark (“?”) Element people { element person { attribute date { text }? Now the instance document can leave out the date attribute and still validate. The document validates, as expected. Just as it's possible to make an attribute optional, it's also possible to make an element optional. <people> <person> <date>2008-06-20</date> </person></people> XML Basics. XML Basics(Page 1 of 4 ) XML stands for eXtensible Markup Language. XML is used to aid the exchange of data.
The language makes it possible to define data in a structured way. XML tags are not predefined like HTML. XML lets you create your own unique tags that are meaningful for your data, hence the use of the term "extensible. " An XML document does not do anything by itself. Using XML, data can be exchanged between incompatible systems. XML is a meta-language. <? Above is an example of an XML document. An XML document must have a root element.