XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] Create a special purpose programming language, in XML, using state transitions

At 2013-10-18 13:50 +0000, David Lee wrote:
To my thinking (perhaps why I struggle with XSLT) ... an <apply-templates> is essentially a GOTO
with the current state (the current context) as input and possibly a 1 or more target states.
I disagree.

To me <xsl:apply-templates> isn't a "GOTO" it is a "Handle this" ... it is an event generator. It generates an event for every node addressed by pushing that node at your stylesheet.

and a <template> is a state description.
No, to me it is more like an event handler. And you can have many event handlers that will handle the event based on the properties expected of the handler. That is why there is a rule in XSLT that only one template rule can fire for each node pushed by the apply templates: there can be only one handler for every event (though that handler can trigger other events, even on the same node).

In a GOTO you know where you are going to. In XSLT when you say "handle this", you are letting the processor decide which handler is going to handle it from the handlers you've prepared.

You don't really know which is going to handle it because your set of handlers might be overridden by an importing stylesheet that is supplying a different set of handlers. Which is all good, because perhaps you need to change the behaviour and your set of handlers is read-only ... the importing stylesheet simply catches the node pushed at your stylesheet before the stylesheet finds it.

The pattern matching ,to me, just adds to the difficulty of understanding the GOTO's
Perhaps because they shouldn't be regarded as "GOTO"s in the first place.

... as it makes
understanding what the target of the GOTO harder to comprehend (because it's really a function of the current state,
which can be quite subtle).

So what am I seeing wrong here ? Maybe if I understood my misconception I would do better at XLST.
Have a go at trying to picture it as event generation and event handling. This is how I explain it to my students.

Check out the diagrams on pages 23, 247 and 251 of my XSLT book that is available for free download on a "try and buy" basis at http://www.CraneSoftwrights.com/training/#ptux ... if you decide not to pay for the book, please delete the copy that you download for free.

. . . . . . . . . . . Ken

--
Public XSLT, XSL-FO, UBL & code list classes: Melbourne, AU May 2014 |
Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/x/ |
G. Ken Holman mailto:gkholman@CraneSoftwrights.com |
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers: http://www.CraneSoftwrights.com/legal |



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS