/** * @see org.apache.excalibur.xml.dom.DOMParser#parseDocument(org.xml.sax.InputSource) */ public Document parseDocument(InputSource arg0) throws SAXException, IOException { return this.parser.parseDocument(arg0); } }
/** * @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.dom.DOMParser#createDocument() */ public Document createDocument() throws SAXException { return this.parser.createDocument(); }
/** * @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); } }
/** * Performs an XPath query on the source. * @param in the Source the XPath is performed on. * @throws SAXException if something goes wrong while adding the XML snippet. */ protected void performXPathQuery(TraversableSource in) throws SAXException { doc = null; try { doc = this.parser.parseDocument(SourceUtil.getInputSource(in)); } catch (SAXException se) { getLogger().error("Warning:" + in.getName() + " is not a valid XML document. Ignoring"); } catch (Exception e) { this.getLogger().error("Unable to resolve and parse document" + e); } if (doc != null) { NodeList nl = processor.selectNodeList(doc.getDocumentElement(), xpath, this.prefixResolver); final String id = in.getName(); AttributesImpl attributes = new AttributesImpl(); attributes.addAttribute("", RESULT_DOCID_ATTR, RESULT_DOCID_ATTR," CDATA", id); attributes.addAttribute("", QUERY_ATTR_NAME, QUERY_ATTR_NAME, "CDATA",xpath); super.contentHandler.startElement(URI, XPATH_NODE_NAME, PREFIX + ":" + XPATH_NODE_NAME, attributes); DOMStreamer ds = new DOMStreamer(super.xmlConsumer); for (int i = 0; i < nl.getLength(); i++) { ds.stream(nl.item(i)); } super.contentHandler.endElement(URI, XPATH_NODE_NAME, PREFIX + ":" + XPATH_NODE_NAME); } }
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); } }
this.doc = this.parser.parseDocument(SourceUtil.getInputSource(source)); } catch (SAXException e) { getLogger().error("Warning:" + xmlFile.getName() + " is not a valid XML file. Ignoring.", e);
/** * 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(); } }