You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Scott Carter <sc...@dotsconnect.com> on 2001/01/16 00:34:11 UTC
SAX2 Error Handling, can anyone help??
I am using the following class as an error handler in an attempt to bubble
my errors up through my application:
----------------------------------begin class
public class SaxErrorHandler implements org.xml.sax.ErrorHandler {
/**
* SaxErrorHandler constructor comment.
*/
public SaxErrorHandler() {
super();
}
/**
* error method comment.
*/
public void error(org.xml.sax.SAXParseException e) throws
org.xml.sax.SAXException {
throw e;
}
/**
* fatalError method comment.
*/
public void fatalError(org.xml.sax.SAXParseException e) throws
org.xml.sax.SAXException {
throw e;
}
/**
* warning method comment.
*/
public void warning(org.xml.sax.SAXParseException e) throws
org.xml.sax.SAXException {
throw e;
}
}
----------------------------------end class
I have also added the following line to set the ErrorHandler in my parser:
parser.setErrorHandler(new SaxErrorHandler());
However, my application is not picking up any errors when bad documents are
sent in. A couple of weeks ago I had alleviated this problem using the SAX1
interface and now I am trying to upgrade to SAX2. Does anyone know what I
might be doing wrong?
Any help is much appreciated...
Scott Carter
Re: DOM output of an XSLTProcessor as a DOM input to another
Posted by Martín Lahittette <ml...@telpin.com.ar>.
Ops!! I'm sorry. I had a bug in my stylesheet. XSLTProcessor works fine with
DocumentImpl DOM as input.
Sorry again and thanks.
----- Original Message -----
From: "Martín Lahittette" <ml...@telpin.com.ar>
To: <xe...@xml.apache.org>
Sent: Monday, January 15, 2001 10:40 PM
Subject: DOM output of an XSLTProcessor as a DOM input to another
> Hi!!
> I'd like to use a DOM output of an XSLTProcessor as a DOM input to another
> XSLTProcessor. Is it posible?
>
> I tried with this code:
>
> import org.apache.xerces.parsers.DOMParser;
> import org.xml.sax.SAXException;
> import org.apache.xalan.xslt.*;
> import org.apache.xalan.xpath.xml.XMLParserLiaison;
> import org.w3c.dom.*;
> import org.apache.xerces.dom.*;
> import java.io.IOException;
>
> .......
>
> org.w3c.dom.Document in, out, end;
>
> DOMParser parser = new DOMParser();
> parser.parse("catalogo.xml");
> in = parser.getDocument();
>
> out = test(in);
> end = test(out);
> .........
>
> // Process the DOM dom with a stylesheet that produce a copy of the input
> DOM.
> public org.w3c.dom.Document test(org.w3c.dom.Document dom) throws
> SAXException {
> org.w3c.dom.Document answ;
>
> XSLTProcessor xsltProc = XSLTProcessorFactory.getProcessor
> (new org.apache.xalan.xpath.xdom.XercesLiaison());
>
> answ = new org.apache.xerces.dom.DocumentImpl();
> XSLTResultTarget resultTarget = new XSLTResultTarget(answ);
>
> xsltProc.process(new XSLTInputSource(dom),
> new XSLTInputSource("catalogo.xsl"),
> resultTarget);
> return answ;
> }
>
> When I call the test method with 'out', it doesn't work ok. It doesn't
throw
> any Exception, but the DOM is not correctly processed.
> I think the problem is that XSLTProcessor work only with a
> DeferredDocumentImpl (as created by the DOMParsed) as input, but it always
> produce a DocumentImpl as output (even if I set 'answ' as a
> DeferredDocumentImpl)
>
> Any help will be much appreciated...
> Thanks, Martin
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
DOM output of an XSLTProcessor as a DOM input to another
Posted by Martín Lahittette <ml...@telpin.com.ar>.
Hi!!
I'd like to use a DOM output of an XSLTProcessor as a DOM input to another
XSLTProcessor. Is it posible?
I tried with this code:
import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.SAXException;
import org.apache.xalan.xslt.*;
import org.apache.xalan.xpath.xml.XMLParserLiaison;
import org.w3c.dom.*;
import org.apache.xerces.dom.*;
import java.io.IOException;
.......
org.w3c.dom.Document in, out, end;
DOMParser parser = new DOMParser();
parser.parse("catalogo.xml");
in = parser.getDocument();
out = test(in);
end = test(out);
.........
// Process the DOM dom with a stylesheet that produce a copy of the input
DOM.
public org.w3c.dom.Document test(org.w3c.dom.Document dom) throws
SAXException {
org.w3c.dom.Document answ;
XSLTProcessor xsltProc = XSLTProcessorFactory.getProcessor
(new org.apache.xalan.xpath.xdom.XercesLiaison());
answ = new org.apache.xerces.dom.DocumentImpl();
XSLTResultTarget resultTarget = new XSLTResultTarget(answ);
xsltProc.process(new XSLTInputSource(dom),
new XSLTInputSource("catalogo.xsl"),
resultTarget);
return answ;
}
When I call the test method with 'out', it doesn't work ok. It doesn't throw
any Exception, but the DOM is not correctly processed.
I think the problem is that XSLTProcessor work only with a
DeferredDocumentImpl (as created by the DOMParsed) as input, but it always
produce a DocumentImpl as output (even if I set 'answ' as a
DeferredDocumentImpl)
Any help will be much appreciated...
Thanks, Martin
RE: SAX2 Error Handling, can anyone help??
Posted by Scott Carter <sc...@dotsconnect.com>.
Thanks for the advice, I forgot to mention that I have this set as well.
lease le me know if oyu see anything else questionable, I am new to SAX2....
-----Original Message-----
From: Milind Gadre [mailto:milind@ecplatforms.com]
Sent: Monday, January 15, 2001 6:43 PM
To: xerces-j-dev@xml.apache.org
Subject: Re: SAX2 Error Handling, can anyone help??
Scott, you may need the following
parser.setFeature("http://xml.org/sax/features/validation", true);
Regards...
>
> I have also added the following line to set the ErrorHandler in my
parser:
>
> parser.setErrorHandler(new SaxErrorHandler());
>
>
> However, my application is not picking up any errors when bad
documents are
> sent in. A couple of weeks ago I had alleviated this problem using
the SAX1
> interface and now I am trying to upgrade to SAX2. Does anyone know
what I
> might be doing wrong?
>
> Any help is much appreciated...
>
> Scott Carter
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: SAX2 Error Handling, can anyone help??
Posted by Milind Gadre <mi...@ecplatforms.com>.
Scott, you may need the following
parser.setFeature("http://xml.org/sax/features/validation", true);
Regards...
>
> I have also added the following line to set the ErrorHandler in my
parser:
>
> parser.setErrorHandler(new SaxErrorHandler());
>
>
> However, my application is not picking up any errors when bad
documents are
> sent in. A couple of weeks ago I had alleviated this problem using
the SAX1
> interface and now I am trying to upgrade to SAX2. Does anyone know
what I
> might be doing wrong?
>
> Any help is much appreciated...
>
> Scott Carter