xml-attributes

Sketch of end-user documentation:

This module is intended to be imported into GRDDL transforms written in 
XSLT1, in order to produce appropriate xml:base and xml:lang attributes.

There are three named templates, one of which should be called when 
producing an element within the GRDDL output, which needs to have 
xml:lang, xml:base attributes or both added according to generally 
useful rules.

The three templates are:

   xa:lang  - may produce an xml:lang attribute.
   xa:base  - may produce an xml:base attribute.
   xa:base-and-lang - may produce either or both attributes.

When there is no information, the templates do not produce attributes.

Each template has a single parameter named "node".
This can be omitted and defaults to the current() node.

The rules used by the templates are as follows:

First, for non-XHTML documents:

- xml:lang is produced according to the inheritance rules, applied to 
$node, as given in the XML Recommendation
- xml:base is produced according to the inheritance rules, applied to 
$node, as given in the XML Base Recommendation. However, an xml:base on 
the root element is ignored, since this will be handled by the GRDDL 
aware agent.

Second, for XHTML documents, in the default processing mode:

- xml:lang is produced according to the inheritance rules, applied to 
$node, as given in the XHTML Recommendation: in particular, if both 
xml:lang and lang attributes are present in the ancestors of $node, 
xml:lang is used. If only one is present, then that is used.
- xml:base is not produced at all, and any xml:base attributes are 
ignored. xml:base is not supported in XHTML (see the XHTML 
Recommendation, in particular the DTD). An HTML Base element, if any, 
will be handled by the GRDDL aware agent

Since, in some instances, a transform may wish to honour xml:base 
attributes within an XHTML document, despite it not being supported by 
the Recommendation, it is possible to change the processing mode by 
setting the variable xa:use-xml-base-in-xhtml to true, e.g.

<xsl:variable name="xa:use-xml-base-in-xhtml"
               select="true()" />

In this case, the processing of xml:base in XHTML documents then follows 
this rule:

- xml:base is produced according to the inheritance rules, applied to 
$node, as given in the XML Base Recommendation, this includes an 
xml:base on the root element which may not be handled by the GRDDL aware 
agent.


====

Note: whenever I have to consider a relative xml:base that needs 
resolving against some other base value, I give up with a terminate="yes".

Jeremy




-- 
Hewlett-Packard Limited
registered Office: Cain Road, Bracknell, Berks RG12 1HN
Registered No: 690597 England

Received on Friday, 15 June 2007 13:49:15 UTC