/** * @see org.apache.excalibur.xml.sax.SAXParser#parse(org.xml.sax.InputSource, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler) */ public void parse(InputSource arg0, ContentHandler arg1, LexicalHandler arg2) throws SAXException, IOException { this.parser.parse(arg0, arg1, arg2); }
/** * @see org.apache.excalibur.xml.sax.SAXParser#parse(org.xml.sax.InputSource, org.xml.sax.ContentHandler) */ public void parse(InputSource arg0, ContentHandler arg1) throws SAXException, IOException { this.parser.parse(arg0, arg1); } }
private void sourceToSAX(Source source, ContentHandler handler) throws SAXException, IOException, SourceException, ProcessingException { if (source instanceof XMLizable) { ((XMLizable) source).toSAX(handler); } else { this.saxParser.parse(SourceUtil.getInputSource(source), handler); } }
/** * Creates a W3C Document that remembers the location of each element in * the source file. The location of element nodes can then be retrieved * using the {@link #getLocation(Element)} method. * * @param inputSource the inputSource to read the document from * @param manager the service manager where to lookup the entity resolver */ public static Document parse(InputSource inputSource, SAXParser parser) throws SAXException, IOException { DOMBuilder builder = new DOMBuilder(); // Enhance the sax stream with location information ContentHandler locationHandler = new LocationAttributes.Pipe(builder); parser.parse(inputSource, locationHandler); return builder.getDocument(); }
public Event execute(final XMLConsumer consumer, ObjectModel objectModel, ExecutionContext executionContext, MacroContext macroContext, NamespacesTable namespaces, Event startEvent, Event endEvent) throws SAXException { Object val; try { val = this.compiledExpression.getNode(objectModel); boolean stripRoot = BooleanUtils.toBoolean(this.stripRoot); // TODO: LG, I do not see a good way to do this. if (BooleanUtils.isTrue(this.xmlize)) { if (val instanceof Node || val instanceof Node[] || val instanceof XMLizable) Invoker.executeNode(consumer, val, stripRoot); else { SAXParser parser = executionContext.getSaxParser(); InputSource source = new InputSource(new ByteArrayInputStream(val.toString().getBytes())); IncludeXMLConsumer includeConsumer = new IncludeXMLConsumer(consumer); includeConsumer.setIgnoreRootElement(stripRoot); parser.parse(source, includeConsumer); } } else Invoker.executeNode(consumer, val, stripRoot); } catch (Exception e) { throw new SAXParseException(e.getMessage(), getLocation(), e); } return getNext(); } }