/** * Test whether this object model recognizes a particular kind of JAXP Source object, * and if it does, send the contents of the document to a supplied Receiver, and return true. * Otherwise, return false. * <p> * This implementation returns true only if the source is a DOMSource whose contained node is a * a "NodeOverNodeInfo". */ public boolean sendSource(Source source, Receiver receiver, PipelineConfiguration pipe) throws XPathException { if (source instanceof DOMSource) { Node startNode = ((DOMSource)source).getNode(); if (startNode instanceof NodeOverNodeInfo) { NodeInfo base = ((NodeOverNodeInfo)startNode).getUnderlyingNodeInfo(); Sender driver = new Sender(pipe); driver.send(base, receiver); return true; } } return false; }
Sender.configureParser(parser); } catch (XPathException err) { throw new TransformerFactoryConfigurationError(err);
sendDocumentInfo(ns, next, loc); return; sendPullSource((PullSource) source, next, options); return; sendSAXSource((SAXSource) source, next, options); return; sendSAXSource(sax, next, options); if (reuseParser) { config.reuseSourceParser(parser); send(ps, next, options); sendPullSource(new PullSource(bridge), next, options); return; } else { next = makeValidator(next, source.getSystemId(), options); newSource instanceof AugmentedSource || newSource instanceof EventSource) { send(newSource, next, options);
/** * Send the contents of a Source to a Receiver. * @param source the source to be copied * @param receiver the destination to which it is to be copied */ public void send(Source source, Receiver receiver) throws XPathException { send(source, receiver, false); }
configureParser(parser); if (parser.getErrorHandler() == null) { parser.setErrorHandler(errorHandler); throw new XPathException(namedParser(parser) + " does not recognize request for XInclude processing", err); } catch (SAXNotSupportedException err) { throw new XPathException(namedParser(parser) + " does not support XInclude processing", err); config.getLogger().warning(namedParser(parser) + " does not recognize the feature " + entry.getKey()); config.getLogger().warning(namedParser(parser) + " does not support the feature " + entry.getKey()); parser.setProperty(entry.getKey(), entry.getValue()); } catch (SAXNotRecognizedException err) { config.getLogger().warning(namedParser(parser) + " does not recognize the property " + entry.getKey()); } catch (SAXNotSupportedException err) { config.getLogger().warning(namedParser(parser) + " does not support the property " + entry.getKey()); throw new XPathException(namedParser(parser) + " does not recognize request for XInclude processing", err); } catch (SAXNotSupportedException err) { throw new XPathException(namedParser(parser) + " does not support XInclude processing", err); receiver = makeValidator(receiver, source.getSystemId(), options);
} else { configureParser(parser); receiver = makeValidator(receiver, source.getSystemId(), options);
private void sendPullEventSource(PullEventSource source, Receiver receiver, ParseOptions options) throws XPathException { boolean xInclude = options.isXIncludeAware(); if (xInclude) { throw new XPathException("XInclude processing is not supported with a pull parser"); } receiver = makeValidator(receiver, source.getSystemId(), options); receiver.open(); EventIterator provider = source.getEventIterator(); if (provider instanceof LocationProvider) { pipe.setLocationProvider((LocationProvider)provider); } receiver.setPipelineConfiguration(pipe); SequenceReceiver out = receiver instanceof SequenceReceiver ? ((SequenceReceiver)receiver) : new TreeReceiver(receiver); EventIteratorToReceiver.copy(provider, out); receiver.close(); }
sendDocumentInfo(ns, next, loc); return; sendPullSource((PullSource) source, next, options); return; sendSAXSource((SAXSource) source, next, options); return; sendSAXSource(sax, next, options); if (reuseParser) { config.reuseSourceParser(parser); send(ps, next, options); sendPullSource(new PullSource(bridge), next, options); return; } else { next = makeValidator(next, source.getSystemId(), options); newSource instanceof AugmentedSource || newSource instanceof EventSource) { send(newSource, next, options);
/** * Send the contents of a Source to a Receiver. Note that if the Source * identifies an element node rather than a document node, only the subtree * rooted at that element will be copied. * @param source the document or element to be copied * @param receiver the destination to which it is to be copied */ public void send(Source source, Receiver receiver) throws XPathException { send(source, receiver, false); }
configureParser(parser); if (parser.getErrorHandler() == null) { parser.setErrorHandler(errorHandler); throw new XPathException(namedParser(parser) + " does not recognize request for XInclude processing", err); } catch (SAXNotSupportedException err) { throw new XPathException(namedParser(parser) + " does not support XInclude processing", err); config.getLogger().warning(namedParser(parser) + " does not recognize the feature " + entry.getKey()); config.getLogger().warning(namedParser(parser) + " does not support the feature " + entry.getKey()); parser.setProperty(entry.getKey(), entry.getValue()); } catch (SAXNotRecognizedException err) { config.getLogger().warning(namedParser(parser) + " does not recognize the property " + entry.getKey()); } catch (SAXNotSupportedException err) { config.getLogger().warning(namedParser(parser) + " does not support the property " + entry.getKey()); throw new XPathException(namedParser(parser) + " does not recognize request for XInclude processing", err); } catch (SAXNotSupportedException err) { throw new XPathException(namedParser(parser) + " does not support XInclude processing", err); receiver = makeValidator(receiver, source.getSystemId(), options);
private void sendPullSource(PullSource source, Receiver receiver, ParseOptions options) throws XPathException { boolean xInclude = options.isXIncludeAware(); if (xInclude) { throw new XPathException("XInclude processing is not supported with a pull parser"); } receiver = makeValidator(receiver, source.getSystemId(), options); PullProvider provider = source.getPullProvider(); if (provider instanceof LocationProvider) { pipe.setLocationProvider((LocationProvider)provider); } provider.setPipelineConfiguration(pipe); receiver.setPipelineConfiguration(pipe); PullPushCopier copier = new PullPushCopier(provider, receiver); try { copier.copy(); } finally { if (options.isPleaseCloseAfterUse()) { provider.close(); } } }
/** * Validate an instance document supplied as a Source object * @param source the instance document to be validated. The call getSystemId() applied to * this source object must return the base URI used for dereferencing any xsi:schemaLocation * or xsi:noNamespaceSchemaLocation attributes * @throws SaxonApiException if the source document is found to be invalid */ public void validate(Source source) throws SaxonApiException { Receiver receiver = getReceiver(config, source.getSystemId()); PipelineConfiguration pipe = receiver.getPipelineConfiguration(); try { new Sender(pipe).send(source, receiver, true); } catch (XPathException e) { throw new SaxonApiException(e); } }
sendDocumentInfo(ns, next); return; throw new XPathException("XInclude processing is not supported with a pull parser"); sendPullSource((PullSource)source, next, schemaValidation, stripSpace); return; sendSAXSource((SAXSource)source, next, schemaValidation, topLevelNameCode, stripSpace, xInclude, dtdValidation == Validation.STRICT, topLevelType); return; sendSAXSource(sax, next, schemaValidation, topLevelNameCode, stripSpace, xInclude, dtdValidation == Validation.STRICT, topLevelType); if (reuseParser) { send(ps, next, isFinal); newSource instanceof PullSource || newSource instanceof AugmentedSource) { send(newSource, next, isFinal);
/** * Test whether this object model recognizes a particular kind of JAXP Source object, * and if it does, send the contents of the document to a supplied Receiver, and return true. * Otherwise, return false. * <p>This implementation returns true only if the source is a DOMSource whose contained node is a * a "NodeOverNodeInfo".</p> */ public boolean sendSource(Source source, Receiver receiver) throws XPathException { if (source instanceof DOMSource) { Node startNode = ((DOMSource) source).getNode(); if (startNode instanceof NodeOverNodeInfo) { NodeInfo base = ((NodeOverNodeInfo) startNode).getUnderlyingNodeInfo(); Sender.send(base, receiver, null); return true; } } return false; }
Sender.configureParser(parser); } catch (XPathException err) { throw new TransformerFactoryConfigurationError(err);
/** * Copy data from a pull source to a push destination * * @param source the pull source * @param receiver the push destination * @param options provides options for schema validation * @throws XPathException if any error occurs */ private static void sendPullSource(PullSource source, Receiver receiver, ParseOptions options) throws XPathException { PipelineConfiguration pipe = receiver.getPipelineConfiguration(); boolean xInclude = options.isXIncludeAware(); if (xInclude) { throw new XPathException("XInclude processing is not supported with a pull parser"); } receiver = makeValidator(receiver, source.getSystemId(), options); PullProvider provider = source.getPullProvider(); provider.setPipelineConfiguration(pipe); receiver.setPipelineConfiguration(pipe); PullPushCopier copier = new PullPushCopier(provider, receiver); try { copier.copy(); } finally { if (options.isPleaseCloseAfterUse()) { provider.close(); } } }
/** * Evaluate in a general context */ public Item evaluateItem(XPathContext c) throws XPathException { Controller controller = c.getController(); AtomicValue content = (AtomicValue)argument[0].evaluateItem(c); StringReader sr = new StringReader(content.getStringValue()); InputSource is = new InputSource(sr); is.setSystemId(baseURI); Source source = new SAXSource(is); source.setSystemId(baseURI); Builder b = controller.makeBuilder(); Receiver s = b; source = AugmentedSource.makeAugmentedSource(source); ((AugmentedSource)source).setStripSpace(Whitespace.XSLT); if (controller.getExecutable().stripsInputTypeAnnotations()) { s = controller.getConfiguration().getAnnotationStripper(s); } try { new Sender(controller.makePipelineConfiguration()).send(source, s); return b.getCurrentRoot(); } catch (XPathException err) { throw new XPathException(err); } }
sendDocumentInfo(ns, next); return; sendPullSource((PullSource)source, next, options); return; sendPullEventSource((PullEventSource)source, next, options); return; sendSAXSource((SAXSource)source, next, options); return; sendSAXSource(sax, next, options); if (reuseParser) { config.reuseSourceParser(parser); send(ps, next, isFinal); next = makeValidator(next, source.getSystemId(), options); newSource instanceof AugmentedSource || newSource instanceof EventSource) { send(newSource, next, isFinal);
/** * Test whether this object model recognizes a particular kind of JAXP Source object, * and if it does, send the contents of the document to a supplied Receiver, and return true. * Otherwise, return false. * <p>This implementation returns true only if the source is a DOMSource whose contained node is a * a "NodeOverNodeInfo".</p> */ public boolean sendSource(Source source, Receiver receiver) throws XPathException { if (source instanceof DOMSource) { Node startNode = ((DOMSource) source).getNode(); if (startNode instanceof NodeOverNodeInfo) { NodeInfo base = ((NodeOverNodeInfo) startNode).getUnderlyingNodeInfo(); Sender.send(base, receiver, null); return true; } } return false; }
Sender.configureParser(parser); } catch (XPathException err) { throw new TransformerFactoryConfigurationError(err);