Declaring the XLink Attributes

Note that if you're creating valid XML documents, you must declare XLink attributes just like any other attributes. For example, you might use a declaration in a DTD like this for the previous example:

Listing ch15_03.xml
 <?xml version = "1.0" standalone="yes"?> <!DOCTYPE MOVIE_REVIEW [ <!ELEMENT MOVIE_REVIEW (#PCDATA)>  <!ATTLIST MOVIE_REVIEW   xmlns:xlink CDATA #IMPLIED   xml:base CDATA #IMPLIED   xlink:type CDATA #REQUIRED   xlink:href CDATA #IMPLIED   xlink:show CDATA #IMPLIED   xlink:actuate CDATA #IMPLIED   xlink:title CDATA #IMPLIED>  ]> <MOVIE_REVIEW xmlns:xlink = "http://www.w3.org/1999/xlink"     xml:base="http://www.starpowder.com"     xlink:type = "simple"     xlink:show = "new"     xlink:href="reviews.xml">     Mr. Blandings Builds His Dream House </MOVIE_REVIEW> 

You can also hard-code the values for most of the values in the XLink attributes if you prefer, in which case you have to supply a value for only the xlink:href attribute:

Listing ch15_04.xml
 <?xml version = "1.0" standalone="yes"?> <!DOCTYPE MOVIE_REVIEW [ <!ELEMENT MOVIE_REVIEW (#PCDATA)> <!ATTLIST MOVIE_REVIEW  xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink"   xml:base CDATA #FIXED "http://www.starpowder.com"   xlink:type CDATA #FIXED "simple"   xlink:href CDATA #REQUIRED   xlink:show CDATA #FIXED "new"   xlink:actuate CDATA #FIXED "onRequest"   xlink:title CDATA #IMPLIED>  ]>  <MOVIE_REVIEW xlink:href="reviews.xml">   Mr. Blandings Builds His Dream House   </MOVIE_REVIEW>  

Because XLink is so general, declaring your XLink elements can get fairly involved. XLink elements may even have child XLink elements, which have their own XLink children, and so on. But keep in mind that if you want to create a valid document, you have to declare them all in a DTD or schema.

We've seen the attributes you can use with XLinks in overview now. Because these attributes define XLinks, I'll take a look at each of them in more detail now, starting with the most important one of all, the xlink:type attribute.



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net