Errata

XSLT Cookbook

Errata for XSLT Cookbook

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 2
Section 1.2 "index-of" template

The template "index-of" incorrectly returns one when the parameter $substr is an
empty string. It should return zero. The culprit is the test with "contains" which
evaluates to true in this case.

One possible workarond is to change the line:

<xsl:when test="contains($input, $substr)">

to:

<xsl:when test="contains($input, $substr) and string-length($substr) > 0">

Anonymous   
Printed Page 83
1st line doesn't match the examples zip file version.

The algorithm for calculate-julian-date is not quite right in the examples zip file.
The book IS correct - the examples zip file does not take into consideration the leap
year days.

Anonymous   
Printed Page 195
2nd code block

Line 8 of code uses key('current-grouping-key', ...) which is not defined in the
example. It probably ought to be 'products-by-category'.

Additionally, the <xsl:template> element is not closed properly.

Anonymous   
Printed Page 198
text:wrap code from chapter 5.6

Wrapping loses characters if the "word" is longer than the wrap width.

<xsl:call-template name="text:wrap">
<xsl:with-param name="input">1234567890123456789012345678901234567890</xsl:with-param>
<xsl:with-param name="width" select="10"/>
</xsl:call-template>

returns:
1234567890
2345678901
3456789012
4567890

Fix (template text:wrap, page 198, recursive template call):

<xsl:with-param name="input" select="substring($input, string-length($line) + 2)"/>
...change to be...
<xsl:with-param name="input" select="normalize-space( substring($input, string-length($line) + 1) )"/>

Anonymous   
Printed Page 205
last plain text paragraph

december 2005 edition of Sal Mangano XSLT Cookbook 2nd edition
Last plain text paragraph on p. 205

I suppose there's a word (eg: don't) missing:

The child element xsl:matching-substring is used to process the substring that
matches the regex and xsl:non-matching-substring is used to process the substrings
that [MISSING?] match the regex.

Anonymous   
Printed Page 212
Example just before section 6.4

Your example will NOT strip an arbitrary XML document of all namespaces since it will
copy over any namespace nodes that are children of any elements in the document.

For example, if you have an xml document similar to:

<root>
<child xmlns="my.namespace">
<pet>my pet</pet>
</child>
<root>

The namespace will still be present in the copied document.

A stylehsheet that DOES strip any and all namespaces, including from the above sample
looks as follows:

<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | * | text()"/>
</xsl:element>
</xsl:template>

<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>

Anonymous   
Printed Page 238-39
Eight examples of logic rather than set theory

All of the examples read @smoker='y' when they should read @smoker='yes', the form of
the data in people.xml. Thus the first example should read
<!-- Male smokers -->
<xsl:variable name="super-risk"
select="//person[@sex='m' and @smoker='yes']"/>

Anonymous   
Printed Page 245
XSLT code

xsl-import statement is missing the initial letter v in the attribute, and should
read <xsl:import href="vset.ops.xslt"/>.

Also the xsl:with-param statements are correct in the book but incorrect in the
downloaded code (unique-people.xslt), where they incorrectly read

<xsl:with-param name="node-set1" ...
<xsl:with-param name="node-set2" ...

instead of

<xsl:with-param name="nodes1" ...
<xsl:with-param name="nodes2" ...

Anonymous