Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

org.xml.sax.SAXParseException: The processing instruction target matching "

843834Jul 28 2004 — edited Jul 29 2004
I'm coding a simple jsp file that parses an XML file.
But i got this Exception:
org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.

This is the jsp file :
<% /*@ page import = "org.xml.sax.ParserFactory"*/ %> <%@ page import = "org.xml.sax.SAXException" %> <%@ page import = "java.io.IOException" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Xerces SAX Parser</title> </head> <body> <% String xmlFile = "file:///C:/jakarta-tomcat-5.0.27/webapps/xerces/simple.xml"; String parserClass = "org.apache.xerces.parsers.SAXParser"; Parser parser = ParserFactory.makeParser(parserClass); try { parser.parse(xmlFile); out.println("DONE"); } catch (Exception se) { out.println(se.toString()); } %> </body> </html>

This is the XMl file (simple.xml):
<?xml version="1.0" encoding="UTF-8"?> <?xml:stylesheet type="text/xsl" href="simple.xsl"?> <breakfast-menu> <food> <name>Belgian Waffles</name> <price>$5.95</price> <description>two of our famous Belgian Waffles </description> <calories>650</calories> </food> <food> <name>Strawberry Belgian Waffles</name> <price>$7.95</price> <description>light Belgian waffles</description> <calories>900</calories> </food> <food> <name>Berry-Berry Belgian Waffles</name> <price>$8.95</price> <description>light Belgian waffles</description> <calories>900</calories> </food> </breakfast-menu>

This is the XSl file (simple.xsl)
<?xml version="1.0"> <HTML xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:12pt; background-color:#EEEEEE"> <xsl:for-each select="breakfast-menu/food"> <DIV STYLE="background-color:teal; color:white; padding:4px"> <SPAN STYLE="font-weight:bold; color:white"><xsl:value-of select="name"/></SPAN> - <xsl:value-of select="price"/> </DIV> <DIV STYLE="margin-left:20px; margin-bottom:1em; font-size:10pt"> <xsl:value-of select="description"/> <SPAN STYLE="font-style:italic"> (<xsl:value-of select="calories"/> calories per serving) </SPAN> </DIV> </xsl:for-each> </BODY> </HTML>

Why that error?
p.s. no space before <?xml version="1.0"...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 26 2004
Added on Jul 28 2004
4 comments
739 views