XSLT is an acronym for "ExtensibleStylesheetLanguageTransformations?
". It is a language designed for transforming XML documents into other formats. There's no restriction on the format of the output, and in particular the somewhat less-well-known XslFormattingObjects
portion of XSL is not a requirement.
XSLT is in the category FunctionalProgrammingLanguage
XSLT does not allow programmers to modify state. XSLT templates behave like pure functions. A light bulb goes on. Trying to write an XSL document with a procedural mind-set is certain to end in frustration. An interesting characteristic of XSLT is that the language syntax is defined to be well-formed, valid XML, which makes it verbose. Imagine the angle brackets as parentheses and it begins to look familiar.
The basic element of an XSL sheet is a template rule. The processor walks the document tree and attempts to match each node with a template rule. When a rule is matched, it is fired, typically resulting in generation of some new text and data, possibly transformed in other ways, and some information copied from the input document. The processor uses a complex syntax in the match patterns, and will recursively process nodes. Some elements can use the XpathLanguage
A simple graphic of the XSL engine, from xml.com:
See Using XML Queries and Transformations
from Wrox Sample chapter from Professional VB XML
Try doing some transformations - http://xslt.sitesfree.com/
Known uses of XSLT
Is XSLT really one of the FunctionalProgrammingLanguages?
No, apparently it is not. Lack of side effects and support for minimal function declarations do not a functional language make. How about function as values, easy and convenient functional composition (=support for lambda expressions), currying to name but a few features of functional languages. A functional language is about manipulating functions, not tree structures. I'm sure that many functional programming afficionados will find the comparison with such a clumsy language appalling.
I tend to think of it as a "rule-based" language - similar in concept to rule based expert systems. -- JeffGrigg
Or, maybe it is:
Some most general functional programming design patterns are supported by the FXSL functional programming library for XSLT:
- "Dimitre Novatchev, author and XSL developer, has written an article demonstrating how functions (templates in XSL) can indeed be passed as a data type using XML namespaces in clever manner. Whether this qualifies templates as first class data types is certainly debatable, but Novatchev's technique makes it clear that XSL can operate as a weakly-typed functional language."
- -- http://www-106.ibm.com/developerworks/xml/library/x-xslrecur/
The following articles describe the support for these design patterns and their use in specific problem areas:
- "Dynamic Functions using FXSL: Composition, Partial Applications and Lambda Expressions"
- "Casting the Dice with FXSL: Random Number Generation Functions in XSLT"
- "An XSL Calculator: The Math Modules of FXSL"
"What kind of language is XSLT?" "XSLT is based on the concepts of functional programming in the tradition of languages such as Lisp, Haskell, and Scheme. A style sheet is made up of templates that are essentially pure functions -- each template defines a fragment of the output tree as a function of a fragment of the input tree, and produces no side effects." http://www-106.ibm.com/developerworks/xml/library/x-xslt/
"The Functional Programming Language XSLT - A proof through examples" http://www.topxml.com/xsl/articles/fp/
Is XSLT a logic language? <xsl:value-of select="current()["@name = /root/path/name"].
Q I am looking for examples that help a complete novice to write a XsltLanguage based transform that will convert plain text to AwikiLikeSite compatible Html format. Is that trivial?
The input to an XSLT stylesheet is XML, not plain text. You COULD wrap your plain text in a pair of tags, and use the pathetic string processing capabilities present, but it would probably be easier to use a TuringMachine
That TuringMachine idea doesn't seem very helpful. Here, if you'd like to try Xslt for your solution, and you need to work with plain text, take a look at the EXSLT extensions at http://www.exslt.org/ - there are more helpful manipulation functions, especially string tokenizers.
Q Could XSLT be considered a member of the family of HomoiconicLanguages? While both program and data are XML, it's not possible for a stylesheet to access its own code.
See also XsltAsSoftLayer