[
Lists Home |
Date Index |
Thread Index
]
- To: xml dev <xml-dev@lists.xml.org>, Anil Philip <goodnewsforyou@yahoo.com>
- Subject: How to embed xml in an html file, and parse the file using Sax?
- From: Anil Philip <goodnewsforyou@yahoo.com>
- Date: Thu, 27 Jul 2006 11:19:48 -0700 (PDT)
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=1n9K2hBvXVLpY6vYbI8qVEWp21KawIytXDXwUUZUCH1stibn+2U7Aewl7Cylw6dSex5CnCyLIzLP2l4+7agagZEE+B10tXRHrXN3bU9bf95IWqyQvVQ3iD8RQw9cgX2T8n9i0xrAxRupMjXRBqhhuPtK90QpNWb9NNxcGllVfTs= ;
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
|