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

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


   

   

    ]


A variation on this, which works equally well, is to delimit the text with empty

elements:


    ]


The effect of this is that the extra newlines and spaces now belong to whitespace-only nodes, which are stripped from the stylesheet and ignored.

Examples

Here are two simple examples using

to control the output of whitespace:

1.
Output first-name and last-name, separated by a space:


 


Another way to achieve the same effect is to use the
concat()
function:


2.
Output a comma-separated list of values:



   ,

   ,

   ,

   



The purpose of the empty

elements is to split the comma and the following newline character into separate text nodes; this ensures that the newline character becomes part of a whitespace-only node and is therefore not copied to the output. The final

element ensures that a newline is written at the end of each record.

Another way to achieve this is with the separator attribute of

:


See Also


on page 280


on this page

xsl:transform

This is a synonym of

, described on page 465. The two element names may be used interchangeably.

Why is it useful to have two names for the same thing? Probably because it's the easiest way for a standards committee to keep all its members happy. More seriously, the existence of these two names is indicative of the fact that some people see XSLT as being primarily a language for transforming trees, while others see its main role as defining presentation styles. Take your pick.

Format

  id? = 
id

  default-collation? = 
uri-list

  default-validation? = “preserve” | “strip”

  exclude-result-prefixes? = 
tokens

  extension-element-prefixes? = 
tokens

  input-type-annotations? = “preserve” | “strip” | “unspecified”

  use-when? = 
expression

  version = 
number

  xpath-default-namespace? = 
uri

  


See Also


on page 465

xsl:value-of

The

instruction constructs a text node, and writes it to the result sequence.

Changes in 2.0

In XSLT 2.0 the value to be output can be obtained by evaluating a contained sequence constructor as an alternative to using the
select
attribute.

A
separator
attribute has been added, allowing a sequence of values to be output separated by spaces, commas, or any other convenient string.

Format

  select? = expression

  separator? = { string}

  disable-output-escaping? = “yes” | “no”>



Position


is an instruction. It is always used as part of a sequence constructor.

Attributes

Name
Value
Meaning
select
optional
XPath Expression
The value to be output.
separator
optional
Attribute value template returning a string
A string to be used to separate adjacent items in the output.
disable-output-escaping
optional, deprecated
yes
or
no
The value
yes
indicates that special characters in the output (such as
<
) should be output as is, rather than using an XML escape form such as
<
. The default value is
no
.

Other books

LIKE RAIN by Elle, Leen
Prison Ship by Bowers, Michael
To Have and to Hold by Serena Bell
Bitter Demons by Sarra Cannon
The Point of Vanishing by Howard Axelrod
All the Devil's Creatures by Barnett, J.D.
Seduced By The General by India T. Norfleet
Cat on a Hot Tiled Roof by Anna Nicholas
Dead Life (Book 2) by Schleicher, D. Harrison