I have an XML document and XSLT style sheet to change up how it displays. Right now I just want the XSLT document to make “Hello World!” show up when the XML document is run, but I am just getting a display of the XML document on the web page.
Here is the XML document (trial Doc.xml):
<?xml-styelsheet type="text/xsl" href="trialDoc.xsl"?>
<people>
<person gender="M">
<firstName>Sam</firstName>
<lastName>McAllister</lastName>
<age>25</age>
</person>
<person gender="F">
<firstName>Kris</firstName>
<lastName>Paolini</lastName>
<age>24</age>
</person>
<person gender="M">
<firstName>Bob</firstName>
<lastName>Turring</lastName>
<age>19</age>
</person>
</people>
And here is my XSL Document (trialDoc.xsl):
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
Hello World!
</xsl:template>
</xsl:stylesheet>
What am I doing wrong?
First, your XML has a typo; you probably wanted
Then, your XSL should produce XML tree – enclose your output with some XML structure with single node at the top:
Alternatively, instruct the XSL processor to generate text output: