[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl conditional: finding the right node
At 2004-02-12 21:21 -0500, Allin Cottrell wrote:
I'm processing a long list of elements (a command reference for a computer program). The enclosing element is "commandlist" and the individual element is "command". Fine. My problem is this: when I process each "command", I need to check whether or not it has any sub-elements (arguments, options) of a sort that would require a display table to be built. XPath tests can return true/false on the presence of child or descendent nodes. One could explicitly write this down ("needs-table=true|false") as an attribute of each "command", but I would rather automate it. I'm trying to figure out how XSL can know the answer before it reaches the elements that would need a prior table-start -- and, of course, re-set the answer when the next "command" comes along. That is thinking too much like a serial programmer, and not a hierarchical processor. Think branches and leaves, or better still, parents, children, siblings, ancestors and descendants. Try not to think of variables (in XSLT variables do not vary) ... check out the inherent facilities in XSLT for processing hierarchies. The pseudo-code for what I'm trying to implement is something like:
The above takes a "pull approach" to the information ... it is easy but less flexible for specialization ... a "push approach" would use multiple template rules and <xsl:apply-templates/>. It's not hard, but I find my students embrace the pull approach much more quickly and I have to push them to use the push style. I hope this helps. ..................... Ken -- Public courses: upcoming world tour of hands-on XSL training events Each week: Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO Washington, DC: 2004-03-15 San Francisco, CA: 2004-03-22 Hong Kong: 2004-05-17 Germany: 2004-05-24 England: 2004-06-07 World-wide on-site corporate, government & user group XML training! G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|