Previous | Table of Contents | Next |
Now that weve gone through the entire gamut of simple link possibilities, its time to reconstruct the A element in XML. Well begin with a simple version and add features so that it becomes clear how XML differs from HTML. Our first version of the A element declares a minimum set of attributes:
<!ELEMENT A ANY> <!ATTLIST A XML-LINK CDATA #FIXED "SIMPLE" HREF CDATA #REQUIRED TITLE CDATA #IMPLIED INLINE (TRUE|FALSE) "TRUE" SHOW (EMBED|REPLACE|NEW) "REPLACE" ACTUATE (AUTO|USER) "USER">
It isnt technically required to provide the options lists for the INLINE, SHOW, and ACTUATE attributes, but it is generally good practice and may save some processing application confusion down the line. |
Our XML A element will now work like its predecessor in the form <A HREF=target.html> or <A HREF=target.html TITLE=My Link!>. The XML-LINK, INLINE, SHOW, and ACTUATE values already have default values specified and dont need to be declared explicitly. The A element is a classic example of a user-actuated, simple in-line link that by default replaces the content of the originating resource with the content of the target resource. So far, so good.
The REV and REL attributes have been replaced for the most part by ROLE and CONTENT-ROLE, respectively. Although we could plow ahead and just create REV and REL attributes for our A element (since they arent used much anyway), its probably a better idea to move them into XML compliance. XML provides a mechanism for remapping the XML-LINK attributes to other attribute names. This is more frequently used in situations where an element already has an attribute named ROLE or TITLE that has nothing to do with linking, but it is also useful for creating backward-compatible attributes. Using this remapping requires the addition of an XML-ATTRIBUTES attribute. The value of this attribute is a list of attribute names in pairs. The first member of a pair must be the standard name of an XML-LINK attribute; the second member is the name of the attribute to which it will be mapped. In our case, this means that the following attribute listing will need to be added to our attribute declaration for the A element:
XML-ATTRIBUTES CDATA #FIXED "ROLE REV CONTENT-ROLE REL" REV CDATA #IMPLIED REL CDATA #IMPLIED
The XML-ATTRIBUTES declaration requires that the value of the REV attribute will be treated as the value of the usual XML ROLE attribute for linking, whereas the value of the CONTENT-ROLE attribute will be made equivalent to the value of the REL attribute.
When remapping attributes, never assign attributes names beginning with XML-. These are reserved for the future use of the XML standard. The examples in the standard use XL- as an alternative prefix. |
The HTML version of the A element includes one feature that cannot be carried over directly into XML. The TARGET attribute is not available, even though giving SHOW a value of NEW might produce similar results. In combination with the SHOW attribute, the TARGET attribute could be mapped to the BEHAVIOR attribute, but the success of that tactic will depend completely on the ability of the processing application to interpret the BEHAVIOR. Web browsers will probably be able to cope with this problem, but XML parsers may not.
The last attribute of the HTML A element that needs to be addressed in XML is the NAME attribute, which is used to create fragment identifiers in HTML. XML-LINK takes a somewhat different approach to creating fragment identifiers, although it isnt that hard to create an A element that looks like HTML but behaves like XML. For now, you can create a NAME attribute for your A element of type ID.
NAME ID #IMPLIED
The XML development community frowns on calling ID-type attributes anything but ID. In the long term, youll want to rename your NAME attributes ID. |
XML, confronted with a simple #fragmentidentifier, will check the list of ID values in a document. The ID values include all attributes defined as type ID, not just those named ID. (Always remember to declare the ID attribute as type ID; otherwise, XML will ignore it.) In this case, XML will be able to use the NAME attribute, since it is of type ID, as a fragment identifier. The result is HTML syntax that smoothly provides XML functionality. Our (mostly) complete A element now looks like the following:
<!ELEMENT A ANY> <!ATTLIST A XML-LINK CDATA #FIXED "SIMPLE" XML-ATTRIBUTES CDATA #FIXED "ROLE REV CONTENT-ROLE REL" HREF CDATA #REQUIRED TITLE CDATA #IMPLIED INLINE (TRUE|FALSE) "TRUE" SHOW (EMBED|REPLACE|NEW) "REPLACE" ACTUATE (AUTO|USER) "USER" REV CDATA #IMPLIED REL CDATA #IMPLIED NAME ID #IMPLIED TARGET CDATA #IMPLIED>
Previous | Table of Contents | Next |