Recent articles:
Popular archives:
Java: A platform for platforms
Sun's reorg may seem promising to shareholders but it's also a scramble for position. The question now is whether Sun can,
or wants to, maintain its hold on Java technology. Especially with enterprise leaders like SpringSource and RedHat investing
heavily in Java's future as a platform for platforms
Also see:
Discuss: Tim Bray on 'What Sun Should Do'
Page 3 of 5
You must associate the shortcut with the unique identifier, accomplished by placing an xmlns attribute on a parent element. For example:
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
The above code announces that, for this element, and all its children, the prefix xsl refers to the namespace http://www.w3.org/1999/XSL/Transform. Whenever you use an element from this namespace, you should prefix it with the shortcut string:
<xsl:stylesheet>
That way a processor that works with elements from a certain namespace can look for xmlns attributes, find the shortcut, then work with the shortcut's elements.
XML lets you store arbitrary data in an organized manner, and it lets you design how to lay it out. Sometimes, however, you may wish to explain exactly how you laid things out.
You can do so with a DTD (document type definition), which further lets your XML parser check that the data you are reading is a well-formed XML document and conforms to your specified layout. A DTD is a contract that specifies an XML document's layout.
However, DTD suffers from not being XML: its roots lie in SGML (Standard Generalized Markup Language), forcing you to learn another language. Moreover, DTDs do not work well with namespaces, and they are not particularly good at nailing down exactly what you can put where. A general push is on to replace DTDs with XML Schema.
XML Schema lets you define an XML document's contents similarly to DTDs, but XML Schema does not suffer from DTD's shortcomings.
Most importantly, XML Schema works well with namespaces. XML Schema can specify your document's appearance far more accurately—letting you specify numbers of elements and the legal strings they can contain better than DTDs. Finally, unlike DTDs, an XML Schema document is an XML document, so the same tools that edit and test your XML can edit and test your XML Schema.
XLink, <a href="..."> on steroids, lets you link to more than one item and have labels and meanings for each link.
The simplest example resembles the HTML version, with some extra attributes:
<a xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://www.artist.com"/>
HTML uses <a> to signify links, but you can use XLink in a variety of XML documents so you are not restricted to using <a>. The xmlns:xlink attribute gives meaning to the other attributes by announcing that this is XLink. The xlink:type="simple" attribute tells the XLink interpreter to keep things simple, and xlink:href="..." represents the real link, just like in HTML.
A more involved sample showing multiple links looks like this:
<artist xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="extended"> <album xlink:type="locator" xlink:label="album" xlink:href="a.html"/> <song xlink:type="locator" xlink:label="single" xlink:href="b1.html"/> <song xlink:type="locator" xlink:label="single" xlink:href="b2.html"/> </object>
In this example, one <artist> links to one album and two singles.