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
9.74Mb size Format: txt, pdf, ePub
ads

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
.

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

Other books

Notable (Smith High) by Bates, Marni
Leviathan by John Birmingham
Found by Harlan Coben
Stairlift to Heaven by Ravenscroft, Terry
Shades of Midnight by Lara Adrian
Malice Aforethought by J. M. Gregson
Fireworks at the Lake by Berengaria Brown