Source documents
Source documents may be read using the doc()
and document()
functions
in the usual way.
The root (document) node of the HTML page is accessible using the extension function
ixsl:page()
(with no arguments). Because the HTML data model is not a direct match
for the XDM data model used by XPath 2.0 and XSLT 2.0, some special considerations apply.
When navigating the HTML DOM, regular elements and attributes are treated as being in no namespace, and their names are always written in lower-case regardless of the actual case used in the HTML page.
As well as exposing regular attributes in the DOM tree, Saxon also exposes pseudo-attributes to
make available information that would be available to a Javascript programmer via JavaScript properties rather than as
DOM attribute nodes. For example, clicking a checkbox changes the checked
property
to true
or false
, but it does not affect the value of the checked
attribute. Saxon
therefore makes the property available as a pseudo-attribute @prop:checked
, where
the namespace prefix prop
is bound to the namespace URI
http://saxonica.com/ns/html-property
. Moreover, Saxon exposes properties of the
style of the element in a similar way: for example the style's font-size
property is available as
the pseudo-attribute @style:fontSize
, where the namespace prefix style
is bound to the namespace URI http://saxonica.com/ns/html-style-property
.
Pseudo-attributes are accessible by explicit name in a path expression, but they are not included
in the results when you read all attributes of an element using @*
. They are also
not copied by xsl:copy
. They can be written as well as read, using
xsl:attribute
, attributes in a literal result element, or
ixsl:set-attribute
.
When you write a style
attribute to the HTML DOM, Saxon parses the value of the
attribute and updates the corresponding properties of the style
object associated
with the DOM element. For example, if you set style="font-size:30px;
font-weight:normal"
on an element E
, Saxon will set
E.style.fontSize
to 30px
and E.style.fontWeight
to
normal
. (Firefox does this automatically, Internet Explorer does not, so this feature
is there to improve portability across browsers.)