Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
The second step is achieved by setting the following declaration in the stylesheet:
In this example, the namespace undeclaration is largely cosmetic. But if the
For information about SOAP, see
http://www.w3.org/TR/soap12-part0/
.
Namespace Prefixes
When a literal result element is copied to the result tree, the element name and attribute names of the new nodes in the result tree will have the same expanded name (that is, local name and namespace URI) as the corresponding nodes in the stylesheet. Unless there is a conflict, the names that are eventually output will also use the namespace prefix that was used in the stylesheet.
There are unusual circumstances when the XSLT processor may need to change the prefix of an element or attribute. Consider the following contrived example:
The generated output in this case will look something like this:
xmlns:ns0=“http://domain-a.com/”
xmlns:p=“http://domain-b.com/”/>
Here the literal result element and its contained
p
. The specification is clear that the
When namespace nodes are copied from the source or stylesheet tree to the result tree, the namespace prefix and namespace URI are both copied unchanged. When element or attribute nodes are copied, the expanded name of the element or attribute (that is, its local name and namespace URI) is always preserved, but the namespace prefix may occasionally need to be changed. If this happens, however, an extra namespace node will be added to the result tree to associate the new namespace prefix with the correct namespace URI.
Namespace Aliasing
In some circumstances, instead of changing the namespace prefix when a literal result element is copied to the result tree, it is necessary to change the namespace URI.
The most obvious situation where this arises is when the output document is itself a stylesheet. This isn't as esoteric a requirement as it may appear—generating a stylesheet can be a very useful technique. For example, if your company changes its house style to use different fonts and colors, you could write an XSLT transformation to convert all your existing stylesheets to the new standard.
When you generate a stylesheet, you will want to generate XSLT elements such as
For more details of this mechanism, see
Attribute Value Templates
As we've seen, an attribute value template is a special form of parameterized attribute value. There are two ways they can be used:
Note that there are very few attributes where this facility is available. They are listed later in this section.
The term
template
here has nothing to do with
An attribute value template is a string in which XPath expressions may be embedded within curly braces (
{
and
}
). The XPath expression is evaluated, and in general the result will be a sequence. This sequence is processed using the same rules as for an