2

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?

1 Answer 1

4

First, your XML has a typo; you probably wanted

<?xml-stylesheet type="text/xsl" href="trialDoc.xsl"?> 

Then, your XSL should produce XML tree - enclose your output with some XML structure with single node at the top:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <h1>Hello World!</h1> </xsl:template> </xsl:stylesheet> 

Alternatively, instruct the XSL processor to generate text output:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="/"> Hello World! </xsl:template> </xsl:stylesheet> 
Sign up to request clarification or add additional context in comments.

1 Comment

I was about to say, I found that misspelling and it worked the way I wanted it too. I was having it generate text output. Thanks for the sharp eye.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.