ENGLISH | JAPANESE |
<< | HOW TO RELAX/Part 1: RELAX Core/STEP 6: Default values, entities, and notations | >> |
default
attribute which provides the default value of an attribute. Existing XML processors will not examine RELAX modules when they parse XML documents. Thus, they will not use default
. The same thing applies to entities and notations: even if RELAX had constructs for declaring entities and notations, existing XML processors would not use them.
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE person [ <!ATTLIST person bloodType CDATA "A"> ]> <person/> |
This document is verified against a RELAX module as below:
<module moduleVersion="1.0" relaxCoreVersion="1.0" xmlns="http://www.xml.gr.jp/xmlns/relaxCore"> <interface> <export label="person"/> </interface> <elementRule role="person"> <empty/> </elementRule> <tag name="person"> <attribute name="bloodType"> <enumeration value="O"/> <enumeration value="A"/> <enumeration value="B"/> <enumeration value="AB"/> </attribute> </tag> </module> |
In this example, the DTD specifies the default value "A". XML processors do use this default. We can verify this XML document against the RELAX module without any problems. Verification is done as if "A" was specified as the attribute value.
Similarly, entities and notations can be described in DTD. First, we show an example of parsed entities.
<?xml version="1.0"?> <!DOCTYPE doc [ <!ENTITY foo "This is a pen"> ]> <doc> <para>&foo;</para> </doc> |
This document is legitimate against the RELAX module as below:
<module moduleVersion="1.0" relaxCoreVersion="1.0" xmlns="http://www.xml.gr.jp/xmlns/relaxCore"> <interface> <export label="doc"/> </interface> <elementRule role="doc"> <ref label="para" occurs="*"/> </elementRule> <elementRule role="para" type="string"/> <tag name="doc"/> <tag name="para"/> </module> |
Next, we show an example of unparsed entities and notations.
<?xml version="1.0"?> <!DOCTYPE doc [ <!NOTATION eps PUBLIC "-//ISBN 0-7923-9432-1::Graphic Notation//NOTATION Adobe Systems Encapsulated Postscript//EN"> <!ENTITY logo_eps SYSTEM "logo.eps" NDATA eps> <!ELEMENT doc EMPTY> <!ATTLIST doc logo ENTITY #IMPLIED> ]> <doc logo="logo_eps"/> |
This document is legitimate against the following RELAX module.
<module moduleVersion="1.0" relaxCoreVersion="1.0" xmlns="http://www.xml.gr.jp/xmlns/relaxCore"> <interface> <export label="doc"/> </interface> <elementRule role="doc" type="emptyString"/> <tag name="doc"> <attribute name="logo" type="ENTITY"/> </tag> </module> |
<< | HOW TO RELAX/Part 1: RELAX Core/STEP 6: Default values, entities, and notations | >> |