OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Java - XMLReader and SAX Filters

[ Lists Home | Date Index | Thread Index ]


Hi,

Girish Patil wrote:
>Hi,
>I am having a similar problem, I am using a custom class that extends
>XMLReader interface to generate the SAX events which I feed into xslt
>processor. It seems to work if I do it in 2 steps, first generate my xml
>files and then use this static xml file and apply transformation to it.
>But if I pass the sax events directly to the processor , it seems to
>ignore my xsl file and just print out the list of all text node.
>I was searching through the list and found You to have similar problem
>with xalan. Did u by any chance figure out why this happens, or what is
>the code solution for this.
>
>Any help would be greatly appreciated :) I am kind of stuck out here:(
>
>thanks
>-Girish



   I couldn't figure it out and gave up on that solution. But what I was asking in my thread had to do with reading the xml from a file using an XMLReader. What you're doing is not quite the same... you're using a class that extends XMLReader to generate the events...

However I'm also using the approach you mention (generating the events...) but I'm extending XMLFilterImpl and not XMLReader.
Using this approach I'm currently having good results and had never got that problem...
Here's a sample of the code I'm using:


import org.xml.sax.*;
import org.xml.sax.helpers.*;
import java.io.*;

public class ExtendedReader extends XMLFilterImpl{

	public ExtendedReader(){
	}

	public void parse(String dummy){

		try {

			startDocument();
			startElement("", "element", "element", new AttributesImpl());
			endElement("", "elements", "elements");
			endDocument();

		} catch (Exception e) {
	     System.err.println("Error:" + e.getMessage());
		}

	}
}


  Cheers,

        Filipe







 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS