You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Uma Shinde <us...@openmarket.com> on 2001/05/29 16:34:25 UTC
Resending: Second parse results in SAXParseException - was: Reade
r gets overwritten, bug?
>>-----Original Message-----
>>From: Uma Shinde [mailto:ushinde@openmarket.com]
>>Sent: Friday, May 25, 2001 2:01 PM
>>To: Xerces-J-User (E-mail); 'shane_curcuru@yahoo.com'
>>Cc: Meena Kamath
>>Subject: FW: Reader gets overwritten, bug?
>>
>>
>>The problem here is that the parser is called twice, once from
>>getAssociatedStylesheet and once from transform. And just
>>calling the parser
>>twice on the same input source does not work. Here's a code
>>snippet I used
>>to verify that.
>>
>> File file = new File(xmlFile);
>> FileReader fstr = new FileReader(file);
>> InputSource inp = new InputSource(fstr);
>> DOMParser p = new DOMParser();
>> p.parse(inp);
>> System.out.println("first Parse");
>> p.parse(inp);
>>
>>The second parse throws this exception:
>>org.xml.sax.SAXParseException: The root element is required
>>in a well-formed
>>document.
>>
>>
>>>>-----Original Message-----
>>>>From: Shane Curcuru [mailto:shane_curcuru@yahoo.com]
>>>>Sent: Thursday, May 24, 2001 10:09 PM
>>>>To: xalan-dev@xml.apache.org
>>>>Subject: Re: Reader gets overwritten, bug?
>>>>
>>>>
>>>>If I recall correctly, that's not a bug (but as I'm
>>>>thinking about it, I'm not sure...)
>>>>
>>>>Basically it's common to only be able to use
>>>>InputStreams/Readers once, and then have to recreate
>>>>them. Thus you probably need to create a new
>>>>StreamSource(new Reader(file.blah)) for the
>>>>getAssociatedStylesheet() call, and then create a
>>>>second StreamSource(new Reader(file.blah)) for the
>>>>stylesheet build. (Or at least a new Reader, to set
>>>>back into the same StreamSource).
>>>>
>>>>I suppose perhaps it shouldn't set the Source you
>>>>passed in to null, but I'm betting that we're not
>>>>going to allow you to re-use the underlying
>>>>Reader/InputSource again.
>>>>
>>>>- Shane
>>>>---- you Meena Kamath <me...@openmarket.com>
>>>>wrote ----
>>>>
>>>>I ran into this problem while using
>>>>getAssociatedStylesheet() to work with
>>>>an embedded stylesheet. To explain this problem
>>>>better, I've attached the
>>>>UseStylesheetPI example that I modified.
>>>>If you notice the transform() and
>>>>getAssociatedStylesheet() use the same
>>>>StreamSource. The StreamSource has been constructed
>>>>using a Reader. On
>>>>execution I get this exception
>>>>
>>>>"javax.xml.transform.TransformerException: The root
>>>>element is required in a
>>>>well
>>>>-formed document.
>>>> at
>>>>org.apache.xalan.transformer.TransformerImpl.transform(Trans
>>formerImp
>>>>l.java, Compiled Code)
>>>> at
>>>>org.apache.xalan.transformer.TransformerImpl.transform(Trans
>>formerImp
>>>>l.java:1174)
>>>> at
>>>>UseStylesheetPI.main(UseStylesheetPI.java:87)....."
>>>>
>>>>On debugging I found that the
>>>>getAssociatedStylesheet() actually sets the
>>>>reader to null. I tried it with FileReader as well as
>>>>StringReader and get
>>>>the same results. Is this a bug?
>>>>
>>>>Thanks
>>>>Meena
>>>>
>>>>
>>>>=====
>>>><eof msg="This is not my regular email account"
>>>> humor="This is not Shane's actual brain today" />
>>>>
>>>>__________________________________________________
>>>>Do You Yahoo!?
>>>>Yahoo! Auctions - buy the things you want at great prices
>>>>http://auctions.yahoo.com/
>>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org