Skip to Content
Java and XSLT
book

Java and XSLT

by Eric M. Burke
September 2001
Intermediate to advanced
528 pages
13h 46m
English
O'Reilly Media, Inc.
Content preview from Java and XSLT

Testing and Debugging

The software development community has shown a renewed interest in testing during the past few years. Much of this has been driven by the eXtreme Programming methodology, which emphasizes lightweight processes and constant unit testing to promote quality.[48] To demonstrate how to test XSLT transformations, a few simple files will be used. The XML data is shown first in Example 9-4.

Example 9-4. aidan.xml

<?xml version="1.0" encoding="UTF-8"?>
<person>
	<firstName>Aidan</firstName>
	<middleName>Garrett</middleName>
	<lastName>Burke</lastName>
	<birthDate month="6" day="25" year="1999"/>
</person>

Although this data is trivial, the same concepts apply to larger, more realistic examples. The sample XSLT stylesheet is shown in Example 9-5.

Example 9-5. condensePerson.xslt

<?xml version="1.0" encoding="UTF-8"?> <!-- *********************************************************** ** Transforms an XML file representing a person into a ** more concise format. ********************************************************--> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="includeMiddle" select="'yes'"/> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" doctype-system="condensed.dtd"/> <!-- match an existing <person> element --> <xsl:template match="person"> <!-- produce a new <person> element in a condensed form --> <xsl:element name="person"> <xsl:element name="name"> <xsl:value-of select="firstName"/> <xsl:text> ...
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.
Start your free trial

You might also like

Learning XSLT

Learning XSLT

Michael Fitzgerald
XSLT

XSLT

Doug Tidwell
XSLT and XPATH: A Guide to XML Transformations

XSLT and XPATH: A Guide to XML Transformations

John Robert Gardner, Zarella L. Rendon

Publisher Resources

ISBN: 0596001436Supplemental ContentCatalog PageErrata