The XML / XSLT Hello World symbol is :
We have this XML document:
<t>Hello <rep/>!</t>
and use this conversion on it :
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="rep"> <xsl:value-of select="'World'"/> </xsl:template> </xsl:stylesheet>
The result obtained is :
<t>Hello World!</t>
Please note :
We use and redefine the rule of identification . This is the most fundamental XSLT design pattern.
We can cross the permanent content from a variety of different replacement elements and thus have a method to "fill the gaps".
Using this technique, you can achieve a complete separation between content and processing logic . XSLT code does not know which source XML document it is processing (the document URL can even be passed as a parameter). In the same XSLT stylesheet, you can use any filling spaces document, and any filling spaces document can be handled by different XSLT stylesheets. This separation provides maximum flexibility and maintainability.
If you only need text that can be created, this can also be done easily - for example, using <xsl:output method="text"/>
source share