4 Replies - 279 Views - Last Post: 20 January 2013 - 05:23 PM

#1 Dankwansere  Icon User is offline

  • D.I.C Head

Reputation: 68
  • Posts: 205
  • Joined: 09-November 09

XML parsing error for XSL

Posted 20 January 2013 - 03:45 PM

I've created a simple XML document with an xsl sheet to render it.

each time I try to display it in the browser I get the following error

"
XML Parsing Error: XML or text declaration not at start of entity
Location: file:///home/dankwansere/Desktop/movies.xml
Line Number 2, Column 1:<?xml -stylesheet href="movies.xsl" type="text/xsl" ?>
^
"

I don't know if the error is from the xml document or the xsl sheet. here are the codes;

movies.xml
<?xml version = "1.0"?>
<?xml -stylesheet href="movies.xsl" type="text/xsl" ?>

<collection> 
			<movie>
					<title>Shawshank Redemptions</title>
					<year>1998</year>
					<genre>drama</genre>
			</movie>
			
			<movie>
					<title>Limitless</title>
					<year>2010</year>
					<genre>suspense</genre>
			</movie>
			
			<movie>
					<title>12 Angry Men</title>
					<year>1960</year>
					<genre>drama</genre>
			</movie>
</collection>






movies.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/collection">
<html>
		<body>
		<table border="1">
					<tr>
								<th>Title</th>
								<th>Genre</th>
								<th>Year</th>
					</tr>
								
					<xsl:for-each select="movie">
					<tr>
							<xsl:value-of select="title" /></td>
							<xsl:value-of select="year" /></td>
							<xsl:value-of select="genre" /></td>
					</tr>
					</xsl:for-each>
					</table>
					
		</body>
</html>
</xsl:template>
</xsl:stylesheet>




Is This A Good Question/Topic? 0
  • +

Replies To: XML parsing error for XSL

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,990
  • Joined: 08-June 10

Re: XML parsing error for XSL

Posted 20 January 2013 - 04:00 PM

The line the error points to should start with <?xml-stylesheet, not <?xml -stylesheet. The space should not be there.
Was This Post Helpful? 1
  • +
  • -

#3 Dankwansere  Icon User is offline

  • D.I.C Head

Reputation: 68
  • Posts: 205
  • Joined: 09-November 09

Re: XML parsing error for XSL

Posted 20 January 2013 - 04:40 PM

Oh okay got it. So for xml you cant have any extra spaces correct?
Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,990
  • Joined: 08-June 10

Re: XML parsing error for XSL

Posted 20 January 2013 - 05:13 PM

Not inside tags like that, no. You can have extra spaces outside tags though.
Was This Post Helpful? 0
  • +
  • -

#5 Dankwansere  Icon User is offline

  • D.I.C Head

Reputation: 68
  • Posts: 205
  • Joined: 09-November 09

Re: XML parsing error for XSL

Posted 20 January 2013 - 05:23 PM

Oh okay thnx
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1