Another XSLT Example, Using XHTML
Example 2-5 contains XML data from an imaginary scheduling program. A schedule has an owner followed by a list of appointments. Each appointment has a date, start time, end time, subject, location, and optional notes. Needless to say, a true scheduling application probably has a lot more data, such as repeating appointments, alarms, categories, and many other bells and whistles. Assuming that the scheduler stores its data in XML files, we can easily add features later by writing a stylesheet to convert the existing XML files to some new format.
Example 2-5. schedule.xml
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="schedule.xslt"?> <schedule> <owner> <name> <first>Eric</first> <last>Burke</last> </name> </owner> <appointment> <when> <date month="03" day="15" year="2001"/> <startTime hour="09" minute="30"/> <endTime hour="10" minute="30"/> </when> <subject>Interview potential new hire</subject> <location>Rm 103</location> <note>Ask Bob for an updated resume.</note> </appointment> <appointment> <when> <date month="03" day="15" year="2001"/> <startTime hour="15" minute="30"/> <endTime hour="16" minute="30"/> </when> <subject>Dr. Appointment</subject> <location>1532 Main Street</location> </appointment> <appointment> <when> <date month="03" day="16" year="2001"/> <startTime hour="11" minute="30"/> <endTime hour="12" minute="30"/> </when> <subject>Lunch w/Boss</subject> <location>Pizza Place on First Capitol Drive</location> ...
Get Java and XSLT now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.