WebReference.com - Excerpt from Inside XSLT, Chapter 2, Part 4 (4/4) | WebReference

WebReference.com - Excerpt from Inside XSLT, Chapter 2, Part 4 (4/4)

To page 1To page 2To page 3current page
[previous]

Inside XSLT

XML Base Support

One of the additions to the XSLT 1.1 working draft was support for the W3C XML Base specification. As of this writing, the XML Base specification is in Proposed Recommendation form (dated 20 December 2000), and you can find the current version of this document at www.w3.org/TR/xmlbase/. [And as of this posting, the recommendation is dated June 27, 2001 - Ed.]

This specification enables you to provide a base URI for XML and XSL documents, just like the HTML <BASE> element. (In fact, the HTML <BASE> element is the reason XBase exists-W3C is committed to giving XML all the power HTML 4.0 linking has, and then build on that.) As you recall, one of the properties of XSL elements is their base URI, and now you can use XML Base to set that URI. However, no XSLT processors that I know of support XML Base yet.

You can find full coverage of XML Base in Inside XML. Here's how it works in overview: You can use the xml:base attribute in an XML document to set the document's base URI. The other URIs in the document are then resolved using that value as a base. Note that xml:base uses the xml namespace; the xml namespace is predefined in XML as "https://www.w3.org/XML/1998/namespace". The following example uses XML links (that is, XLinks, as also covered in Inside XML):

<?xml version="1.0"?>
<MOVIE_REVIEW xmlns:xlink = "https://www.w3.org/1999/xlink"
    xml:base="https://www.starpowder.com/"
    xlink:type = "simple"
    xlink:show = "new"
    xlink:href = "reviews.xml">
    Mr. Blandings Builds His Dream House
</MOVIE_REVIEW>

Using the value assigned to the xml:base attribute, the URI in this example's xlink:href attribute, "reviews.xml", is resolved to the full URI "https://www.starpowder.com/reviews.xml". In this way, you can use xml:base to provide a base URI for a document or a specific element.

In the XSLT 1.1 working draft, every node has an associated URI called its base URI, which is used for resolving attribute values that represent relative URIs into absolute URIs. Here's how you determine the base URI:

Setting the base URI of documents and elements can be useful if you have an extensive set of documents to work with. If you reorganize that document set, you need to reset only the base URI as appropriate, not all individual URIs. As I said, however, no XSLT processors that I know of have any support for XML Base yet.


To page 1To page 2To page 3current page
[previous]

Created: October 4, 2001
Revised: October 4, 2001


URL: https://webreference.com/authoring/languages/xml/insidexslt/chap2/4/4.html