Numbers in predicates Predicates

page 50

3.3 Attribute Value Templates

Although theyre technically defined in the XSLT specification in section 7.6.2, to be exact, well discuss attribute value templates here. An attribute value template is an XPath expression that is evaluated, and the result of that evaluation replaces the attribute value template. For example, we could create an HTML table element like this: table border={size} In this example, the XPath expression size is evaluated, and its value, whatever that happens to be, is inserted into the output tree as the value of the border attribute. Attribute value templates can be used in any literal result elements in your stylesheet for HTML elements and other things that arent part of the XSLT namespace, for example. You can also use attribute value templates in the following XSLT attributes: • The name and namespace attributes of the xsl:attribute element • The name and namespace attributes of the xsl:element element • The format , lang , letter-value , grouping-separator , and grouping-size attributes of the xsl:number element • The name attribute of the xsl:processing-instruction element • The lang , data-type , order , and case-order attributes of the xsl:sort element

3.4 XPath Datatypes

An XPath expression returns one of four datatypes: node-set Represents a set of nodes. The set can be empty, or it can contain any number of nodes. boolean Represents the value true or false . Be aware that the true or false strings have no special meaning or value in XPath; see Section 4.2.1.2 in Chapter 4 for a more detailed discussion of boolean values. number Represents a floating-point number. All numbers in XPath and XSLT are implemented as floating-point numbers; the integer or int datatype does not exist in XPath and XSLT. Specifically, all numbers are implemented as IEEE 754 floating- point numbers, the same standard used by the Java float and double primitive types. In addition to ordinary numbers, there are five special values for numbers: positive and negative infinity, positive and negative zero, and NaN , the special symbol for anything that is not a number. string Represents zero or more characters, as defined in the XML specification. These datatypes are usually simple, and with the exception of node-sets, converting between types is usually straightforward. We wont discuss these datatypes in any more detail here; instead, well discuss datatypes and conversions as we need them to do specific tasks.