[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Tree-walking (was: index-of() behavior)

Florent Georges lists at fgeorges.org
Thu Mar 19 20:38:37 PST 2009


  Tree-walking (was: index-of() behavior)
Michael Kay wrote:

> To get close to emulating apply-templates, I think you need
> a function M that maps node-names to functions T, so you pass
> M to your tree-walking function W, and W when it reaches a node
> N calls M to obtain the function T corresponding to the node-name
> of N, and then calls T. (M=mode, T=template).

  Very interesting.  Except that I would define M as mapping a node (not a node name) to functions, to emulate match patterns.  But I guess a general, user-defined function to map from nodes to functions would be less than optimal.  I guess I am too much XSLT-oriented, but a set of pairs of match patterns (as defined by XSLT) and function objects sounds reasonable to me:

    M1 := (("pattern1", T1),
           ("pattern2", T2),
           ("pattern3", T3),
           ...)

    M2 := (("pattern-a", Ta),
           ("pattern-b", Tb),
           ("pattern-c", Tc),
           ...)

  One obvious advantage of what you describe is that W is not fixed, and could be defined by the user or by a library, and be reused, instead of having to write it again and again as in XSLT.

  I thought a few weeks ago that it would be interesting to expose patterns as first-class objects, even in XSLT.  It seems this would be an interesting application.

  Regards,

-- 
Florent Georges
http://www.fgeorges.org/






















      



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-2011 All Rights Reserved.