[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Breaking from the loop (for-each or apply-template
Hi,
The specification of xsl:message is soft, the instruction optional, and not all processors support it. I suppose this softness is simply out of a recognition that not all architectures are equally able to provide the functionality. A more conventionally XSLT-ish way to approach the problem would be to define the error condition up front and simply design the stylesheet to return warnings instead of (or in addition to) the usual thing, if any error conditions obtain. So for example if I defined my condition as "all <value> elements must have content that casts to a number" (so, for example, "0" is okay but not just whitespace) and my input had (somewhere inside) <value>5</value> <value>9</value> <value></value> <value>Hooey!</value> my XSLT could have <xsl:variable name="errors" select="//value(not(number(.))"/> <xsl:template match="/"> <xsl:choose> <xsl:when test="$errors"> <!-- erroneous 'value' elements are found --> <xsl:apply-templates select="$errors" mode="report-errors"/> </xsl:when> <xsl:otherwise> <!-- no errors: process normally --> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </xsl:template> As noted above, you could leave out the xsl:choose and have the errors reported in addition to, rather than instead of, normal output. Note that this approach only works on "errors" that can be defined ahead and that appear within otherwise proper well-formed XML. Also, no "loop" is being "broken" -- no specification of flow of control is really needed here, just a plain old declaration that "if X is true, I want X', otherwise I want Y". Cheers, Wendell At 03:20 PM 8/12/2005, you wrote: Oleg, ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|