[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: [XSL] Accessing part of the result tree illustrate

Subject: RE: [XSL] Accessing part of the result tree illustrated with "The Sudoku solver" example.
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 5 Sep 2007 08:42:37 +0100
RE:  [XSL] Accessing part of the result tree illustrate
> But experts as you are, you would have noticed that there is a major 
> BUG: even when we have found the solution, the recursion continues!..
> So you can get "lucky" and find a solution in the first seconds, then 
> run for many minutes uselessly just terminating the recursion.

A Sudoku puzzle can in general have more than one solution, and I think,
without studying it in detail, that your code is written to find all the
solutions. If you only want the first solution, the answer is to do:

<xsl:variable name="all-solutions" as="...">
  ... your algorithm here ...
</xsl:variable>
<xsl:sequence select="$all-solutions[1]"/>

An intelligent pipelined XSLT processor will evaluate $all-solutions lazily,
and will recognize the "[1]" as indicating that after finding the first
element in $all-solutions, no further processing is needed.

Michael Kay
http://www.saxonica.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.