The XML/XSLT equivalent of Hello World is this:
We have this XML document:
<t>Hello <rep/>!</t>
and use this transformation 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 wanted result is produced:
<t>Hello World!</t>
Do note:
We use and override the identity rule. This is the most fundamental XSLT design pattern.
We can intersperse a constant content with many different replacement elements and thus have a "fill-in the blanks" technique.
Using this technique a full separation between content and processing logic can be achieved. The XSLT code doesn't know what source XML document it is processing (the document URL can even be passed as parameter). The same XSLT stylesheet can be used any fill-in the blanks document and any fill-in the blanks document can be processed by different XSLT stylesheets. This separation achieves maximum flexibility and maintainability.
If you only want just text to be produced, this can also be done easily -- for example using <xsl:output method="text"/>