← Prev in month ← Prev in thread

How to embed xml in an html file, and parse the file using Sax?

From
Anil Philip <>
To
xml dev <>, Anil Philip <>
Date
2006-07-27T18:19:48Z
ID
<>
Thread
How to embed xml in an html file, and parse the file using Sax?
I have an interesting design problem and wondered if
the gurus would have insight into it.
I need to have an html file that contains or embeds
data in xml and can be parsed by SAX.
  My xml file is like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<JWO
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\Projects\ACD\jwo_schema01.xsd">
</JWO>

  I want to put it inside or embed it in an html file.
The HTML file will be parsed by a SAX
parser, the html ignored, and the XML data extracted.
  When I posted this question long ago, some
(Megginson, Dane...) suggested I put the xml in
the <head> tags and use xhtml.
  So I implemented this:
  ---------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <xml version="1.0" encoding="ISO-8859-1">
<JWO
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\Projects\ACD\jwo_schema01.xsd">
</JWO>
</xml>
<title></title>
<meta http-equiv="KEYWORDS" content=""/>
<meta http-equiv="DESCRIPTION" content=""/>
</head>

  Rest of the html.............
  ----------
  In my content handler,
  
 public void characters(char[] text, int start, int
length) throws SAXException {
  if(skipContent) {
   skipContent = false;
   return;
  }
  else..............
  
 public void startElement(String namespaceURI, String
localName, String qualifiedName,
   Attributes atts) throws SAXException {
  if(!namespaceURI.equalsIgnoreCase("http://www.w3.org/2001/XMLSchema-instance
  ")) {
   skipContent = true;
   return;
  } else............
  
 public void endElement(String namespaceURI, String
localName, String qualifiedName)
   throws SAXException {
  if(!namespaceURI.equalsIgnoreCase("http://www.w3.org/2001/XMLSchema-instance
  ")) {
   skipContent = false;
   return;
  } else............
  -----------
However I get parse errors
eg.
java.net.UnknownHostException: www.w3.org
 at java.net.PlainSocketImpl.connect(Unknown Source)

When I simply remove the <xml> tag and keep it as:
<?xml version="1.0" encoding="ISO-8859-1"?>

ie. inserting the xml file in between the <head>
elements,
then "namespaceURI"= "http://www.w3.org/1999/xhtml"
even while parsing the xml, so it fails
	
  Anyone knows how to do this?
Or is the answer that it cannot be done?
-
Any help appreciated plus you will have the
gratification of having contributed to a useful XML
tool that IMHO will benefit society.
  sincerely,
Anil



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com
← Prev in month ← Prev in thread