XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (199 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
11.34Mb size Format: txt, pdf, ePub

Choice of Prefixes in the Result Document

XSLT 2.0 has clarified the rules defining what prefixes are used in the result. This can be important; for example, if the target stylesheet contains an expression such as
system-property(“xslt:version”)
, then this will only work if the prefix
xslt
has been declared. Follow through exactly what happens when you write the stylesheet:

                xmlns:xsl=“http://www.w3.org/1999/XSL/Transform”

                xmlns:oxsl=“http://localhost/old.uri”>



  



This transformation executes just one instruction: the

literal result element. Namespace aliasing causes this to generate an element with prefix
xsl
, local name
stylesheet
, and namespace URI
http://www.w3.org/1999/XSL/Transform
. The literal result element has two namespace nodes, representing the prefix bindings
xmlns:xsl=“http://www.w3.org/1999/XSL/Transform”
and
xmlns:oxsl=“http://localhost/old.uri”
(we will ignore the namespace node for the
xml
namespace). The first of these is copied to the result tree, because it matches the
result-prefix
, despite the fact that it would normally be an excluded namespace. The second namespace node is not copied, because its namespace URI (
http://localhost/old.uri
) is the one referred to by the
stylesheet-prefix
attribute. So the namespace node in the result tree will map the prefix
xsl
to the namespace URI
http://www.w3.org/1999/XSL/Transform
.

Other books

The Bride Insists by Jane Ashford
Bridge of Mist and Fog by nikki broadwell
The Christmas Portrait by Phyllis Clark Nichols
Our Song by Morse, Jody, Morse, Jayme
Rock Into Me by Susan Arden