You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by tm...@apache.org on 2002/08/29 18:01:49 UTC
cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/trax TrAXFilter.java
tmiller 2002/08/29 09:01:48
Modified: java/src/org/apache/xalan/xsltc/trax TrAXFilter.java
Log:
added some check for parents of filter chain
Revision Changes Path
1.3 +44 -26 xml-xalan/java/src/org/apache/xalan/xsltc/trax/TrAXFilter.java
Index: TrAXFilter.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TrAXFilter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TrAXFilter.java 29 Aug 2002 13:52:40 -0000 1.2
+++ TrAXFilter.java 29 Aug 2002 16:01:48 -0000 1.3
@@ -69,6 +69,7 @@
import org.xml.sax.XMLReader;
import org.xml.sax.InputSource;
import org.xml.sax.helpers.XMLFilterImpl;
+import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.ContentHandler;
import javax.xml.transform.Templates;
import javax.xml.transform.TransformerConfigurationException;
@@ -86,7 +87,7 @@
* skeleton extension of XMLFilterImpl for now.
*/
public class TrAXFilter extends XMLFilterImpl {
- private Templates _templates;
+ private Templates _templates;
private TransformerHandlerImpl _transformer;
public TrAXFilter(Templates templates) throws
@@ -97,45 +98,62 @@
(TransformerImpl) templates.newTransformer());
}
- public void setParent(XMLReader parent) {
- super.setParent(parent);
+ private void createParent() throws SAXException {
+ XMLReader parent = null;
+ try {
+ SAXParserFactory pfactory = SAXParserFactory.newInstance();
+ pfactory.setNamespaceAware(true);
+ SAXParser saxparser = pfactory.newSAXParser();
+ parent = saxparser.getXMLReader();
+ }
+ catch (ParserConfigurationException e) {
+ throw new SAXException(e);
+ }
+ catch (FactoryConfigurationError e) {
+ throw new SAXException(e.toString());
+ }
+
+ if (parent == null) {
+ parent = XMLReaderFactory.createXMLReader();
+ }
+
+ // make this XMLReader the parent of this filter
+ setParent(parent);
}
- public void parse (InputSource input)
- throws org.xml.sax.SAXException, IOException
+ public void parse (InputSource input) throws SAXException, IOException
{
if (getParent() == null) {
- XMLReader reader = null;
- try {
- SAXParserFactory pfactory = SAXParserFactory.newInstance();
- pfactory.setNamespaceAware(true);
- SAXParser saxparser = pfactory.newSAXParser();
- reader = saxparser.getXMLReader();
- }
- catch (ParserConfigurationException e) {
- throw new SAXException(e);
- }
- catch (FactoryConfigurationError e) {
- throw new SAXException(e.toString());
- }
+ try {
+ createParent();
+ }
+ catch (SAXException e) {
+ throw new SAXException(e.toString());
+ }
}
+
+ // call parse on the parent
getParent().parse(input);
}
- public void parse (String systemId) throws org.xml.sax.SAXException,
- IOException
+ public void parse (String systemId) throws SAXException, IOException
{
parse(new InputSource(systemId));
}
- public void setContentHandler (ContentHandler handler)
+ public void setContentHandler (ContentHandler handler)
{
_transformer.setResult(new SAXResult(handler));
+ if (getParent() == null) {
+ try {
+ createParent();
+ }
+ catch (SAXException e) {
+ return;
+ }
+ }
getParent().setContentHandler(_transformer);
}
- public void setErrorListener (ErrorListener handler)
- {
- //_transformer.setErrorListener(handler);
- }
+ public void setErrorListener (ErrorListener handler) { }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org