This work is licensed under a Creative Commons |
Because XML can be used to represent any vocabulary (often defined by some schema), the question is how these different vocabularies can be processed and maybe transformed into something else. This something else
maybe another XML vocabulary (a common requirement in B2B scenarios), or it may be HTML (a common scenario for Web publishing). Using XSL Transformations (XSLT), mapping tasks can be implemented easily. XSLT leverages XPath's expressive power in a rather simple programming language. For easy tasks, XSLT mapping can be specified without much real programming
going on, by simply specifying how components of the source markup are mapped to components of the target markup.
<xsl:for-each select=".//a"> <xsl:if test="not(@title)"> <xsl:text>This link has no title!</xsl:text> </xsl:if> </xsl:for-each> <xsl:for-each select=".//a[not(@title)]"> <xsl:text>This link has no title!</xsl:text> </xsl:for-each>
default behaviormay seem strange
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> </xsl:stylesheet>
textof the document is produced
appliedby the XSLT processor
spaghetti code
Hello Worldin XSLT
hello worldtherefore ignores the input
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:text>Hello World!</xsl:text> </xsl:template> </xsl:stylesheet>
<xsl:for-each select="people/entry"> <tr> <td align="right"><xsl:value-of select="name/pre[1]"/></td> <td align="left"><xsl:value-of select="name/sur"/></td> <td align="center"><a href="mailto:{email}"><xsl:value-of select="email"/></a></td> </tr> </xsl:for-each>