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] A more fundamental concept than functions: units of code thatself-select

> Are there other programming languages that support self-selecting units
of code?
David already pointed to C++ and Java.

Add perl, awk and even sed to that list (/regexp/ selectors).

Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler, L3
WebSphere DataPower SOA Appliances
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

             "Costello, Roger                                              
             <costello@mitre.o                                          To 
             rg>                       "xml-dev@lists.xml.org"             
             05/18/2010 12:27                                           cc 
                                       [xml-dev] A more fundamental        
                                       concept than functions: units of    
                                       code that self-select               

Hi Folks,

XSLT has xsl:template and xsl:function. On the surface they appear to be
the same: you invoke a template rule using xsl:apply-templates and you
invoke a function by dereferencing its name; you can pass parameters to
both; both return values.

Clearly the idea of "function" is a fundamental concept in Computer

It occurs to me that the functionality provided by template rules represent
an even more fundamental concept. In fact, functions are merely a subset of
the functionality provided by template rules.

Allow me to explain.

Consider these three template rules:

    <xsl:template match="Book[Publisher lt 1970]">

    <xsl:template match="Book[Publisher eq 1970]">

    <xsl:template match="Book[Publisher gt 1970]">

Suppose that Book is the context node and it has a Publisher child element
with value 1970. With this apply-templates:

    <xsl:apply-templates select="." />

the second xsl:template rule will fire. Of the three template rules, the
second one self-selected ("I meet the requisite conditions; I will now
activate myself").

Template rules have the ability to self-select. Functions never
self-select. They must always be explicitly called out.

Template rules can also be explicitly called out. Consider these revised

    <xsl:template match="*" mode="pre-1970">
        <param name="Book" />

    <xsl:template match="*" mode="eq-1970>
        <param name="Book" />

    <xsl:template match="*" mode="post-1970">
        <param name="Book" />

The second template can be explicitly called out:

    <xsl:template select="." mode="eq="1970">
        <xsl:with-param name="Book" select="." />

Each template rule is "named" using mode. Effectively the mode is used as
the name of the template rule.

So template rules are units of code that can be either explicitly called
out, or can self-select.

Functions are units of code that can only be explicitly called out.

The ability to create self-selecting units of code is very powerful. It
resounds of decentralization, local-control, Complex Systems. Wow!

Are there other programming languages that support self-selecting units of

Do you agree that self-selecting units of code represents a more
fundamental concept than functions?



XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php

[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