Home > SOA Tips > XML Developer > Error and exception handling in XSLT processing
SOA Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

XML DEVELOPER

Error and exception handling in XSLT processing


Ed Tittel
10.20.2005
Rating: --- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


This is the final installment in our series of tutorial tips on the subject of the XML Style Sheet Language Transformations, aka XSLT. It deals with the various mechanisms that XSLT provides for handling errors if and when they should occur when processing input documents and creating output documents.

The ways in which errors may be handled when using an XSLT processor to handle a document depend in large part on the kinds of errors encountered during processing. These fall broadly into several categories, each of which requires a somewhat different response, but all are part of document processing and thus fall under the purview of the particular XSLT processor that may be in use. That said, it's possible to encounter unknown or unrecognized XSLT function calls, expressions, or mysterious syntax in an XSLT document itself. This is where the notion of fallback comes into play, which basically defines alternative processing instructions that the processor should follow when it encounters instructions it doesn't recognize or can't understand. The xsl:fallback instruction handles this sort of thing (and is covered in the next paragraph). Otherwise, each of the various XSLT processors (Xalan, Saxon, MSXML, and so forth) includes its own unique set of exception handling tools that must be brought to bear on handling errors in input documents being processed (these are covered in a broad way in the next two paragraphs, with pointers to additional information on specifics for key XSLT processors).

At present XSLT processors typically only need to use xsl:fallback when processor specific extensions appear in XSLT documents However, when a new version of XSLT becomes available -- this will probably be named XSLT 2.0 -- this instruction will also serve to resolve discrepancies between processors designed to handle the older version and constructs or syntax they may not therefore recognize from the newer version. Basically, the xsl:...


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
XML Developer
Use the soapUI software tool to tame WSDL
WSDL 2.0, new messaging for Web services
Using RELAX NG For data integration
Efficient XML Interchange tackles data verbosity
XML to DDL imports, synchronizes database schemata
The basics of MathML 3.0
Migrating to XSLT 2.0
What's up with XML 2.0?
Say hello to XPath 2.0
Podcasting software covers many bases

XML and XML schema
What's the future of XML?
SOA pattern of the week (#7): policy centralization
Try XML-based Extensible Business Reporting Language (XBRL) for accounting reports
What's new at the W3C
Ganymede: Modeling tools target SOA, UML
Data services mashups emerge for SOA
Making sense of data services mashups
XML turns 10
SOA helps save 100-year-old business
Oracle maps heterogeneous data services strategy for SOA

XML security
Verizon uses BPEL app to cut down on code, check for fraud, and go green
Layer 7 adds SPARC
Oracle maps heterogeneous data services strategy for SOA
Partnership aims at governance for SOA and Web 2.0
SOA, Web services create software security challenges
Efficient XML Interchange tackles data verbosity
XML to DDL imports, synchronizes database schemata
The case against WS-Security
Layer 7 offers SOA 'virtual soft-appliance'
XQuery 1.0: A long time coming, now what?

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
class diagram  (SearchSOA.com)
Fast Infoset (FI)  (SearchSOA.com)
GeoRSS  (SearchSOA.com)
Keyhole Markup Language  (SearchSOA.com)
RELAX NG  (SearchSOA.com)
state diagram  (SearchSOA.com)
Universal Business Language  (SearchSOA.com)
Vector Markup Language  (SearchSOA.com)
XML infoset  (SearchSOA.com)
XML pipeline  (SearchSOA.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


fallback
instruction is used within a template body and must contain one or more of its own template bodies. It's also important to make sure to nest the fallback instruction within the element that may need recourse to fallback mechanisms. It's likewise important when using elements from within the xsl namespace to include a version attribute that correctly identifies the applicable version number when using some version other than 1.0 (as in ).

This mechanism only deals with XSL version compatibility or processor extension issues, and then only defers the REAL XSLT error-handling mechanisms available to stylesheet and related application developers -- namely, XSLT processor exception and error handling mechanisms. To some extent, these derive directly from the underlying languages or toolsets in use (so that standard Java exception handling techniques work well with Xalan or Saxon, standard .NET techniques with ASP or MSXML, built-in error-handlers support other XML environments like Struts, and so forth). These will generally consist of some method to send a message or alert to report that an error has been encountered, with whatever kind of error-handling and clean-up mechanisms the developer sees fit to provide or invoke from a standard toolset; these may include simple logging, close-out and process termination, or something more complex and capable -- though the processor must terminate without producing a final result tree, according to W3C specifications.

Microsoft has a good example on its Web site titled "Performing Error Handling with XSLT" that restates my categories in terms of parse errors versus run-time errors, but that still addresses both sides of the same divide. Version 2.0 of the XSLT W3C Working Draft (last updated on 9/15/2005) also includes a section (2.9) on error handling that does a great job of defining an error taxonomy and of describing appropriate handling mechanisms. But when the rubber meets the road, the details that apply to the specific processor in use will ultimately reign supreme:

  • Xalan: see discussions throughout the Apache XML FAQ on Xalan
  • Saxon: see discussion at Coverpages.org on SAXON element handlers
  • MSXML: CodeProject has great pointers to general mechanisms, along with an even better discussion of an actual, small-footprint implementation

For other processors, a little searching on " exception handling" or " error handling" should also produce useful information, instructions, and often, examples of how to build or use these things in your own markup.

This concludes my multi-part series on the subject of XSLT. Expect to see me playing catch-up on recent XML tools, news and technologies in my next few tips. If you're interested in seeing similar coverage of other topics, shoot me an E-mail at etittel@techtarget.com and please let me know. I can only hope you've found this series as interesting and informative to read and ponder, as I found it to research and write.

About the author
Ed Tittel is a full-time writer and trainer whose interests include XML and development topics, along with IT Certification and information security topics. E-mail Ed with comments, questions, or suggested topics or tools for review.


Rate this Tip
To rate tips, you must be a member of SearchSOA.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



SOA Trends and Strategy - SOA Education, SOA Development, SOA Implementations
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2001 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts