[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

  • To: xml dev <xml-dev@l...>, Anil Philip <goodnewsforyou@y...>
  • Subject: How to embed xml in an html file, and parse the file using Sax?
  • From: Anil Philip <goodnewsforyou@y...>
  • 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= ;

embed xml in html
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 

Purchase Stylus Studio Online Today!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.