Skip to Content
XSLT Cookbook
book

XSLT Cookbook

by Sal Mangano
December 2002
Intermediate to advanced
672 pages
16h 53m
English
O'Reilly Media, Inc.
Content preview from XSLT Cookbook

Testing Boundary and Error Conditions

Problem

You are writing utility templates to be used by others, and you want them to be robust.

Solution

Boundary-condition testing

In all programming languages, bugs most often appear at boundary conditions. Thus, you should choose test data in which values lie along data extremes. Boundary values include maximum, minimum, and just inside/outside boundaries. If your templates work correctly for these special values, then they will probably work correctly for all other values. It is impossible to provide an exhaustive list of boundary conditions because they vary from problem to problem. Below is a list of typical cases you should consider.

If a template acts on node sets, then be sure to test the following cases:

  • An empty node set

  • A node set with one element

  • A node set with two elements

  • A node set with an odd number of elements other than 1

  • A node set with an even number of elements other than 2

If a template acts on a string, be sure to test the following cases:

  • The empty string

  • A string of length 1

  • Other strings of varying sizes

If your template uses substring-before or substring-after for searches, be sure to test the following cases:

  • Strings that do not contain the test string

  • Strings that start with the search string

  • Strings that end with the search string

  • Strings that contain only the search string

If a template acts on numbers, be sure to test:

  • The number 0

  • The number 1

  • Negative numbers

  • Fractional numbers (0 < x < 1)

  • Numbers with whole and fractional ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

XSLT Cookbook, 2nd Edition

XSLT Cookbook, 2nd Edition

Sal Mangano
XSLT

XSLT

Doug Tidwell
Inside XSLT

Inside XSLT

Steven Holzner

Publisher Resources

ISBN: 0596003722Catalog PageErrata