本文整理汇总了Java中net.sf.saxon.event.Receiver类的典型用法代码示例。如果您正苦于以下问题:Java Receiver类的具体用法?Java Receiver怎么用?Java Receiver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Receiver类属于net.sf.saxon.event包,在下文中一共展示了Receiver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
public static boolean init(Transformer transformer, final LocalDebugger dbg) {
if (transformer instanceof Controller) {
System.out.println("SAXON 9");
final Controller controller = (Controller)transformer;
((Saxon9TraceListener)controller.getConfiguration().getTraceListener()).setDebugger(dbg);
controller.getConfiguration().setLineNumbering(true);
controller.getConfiguration().setCompileWithTracing(true);
controller.getConfiguration().setMultiThreading(false);
controller.getConfiguration().setSerializerFactory(new SerializerFactory(controller.getConfiguration()) {
@Override
protected Receiver createXMLSerializer(Emitter emitter,
Properties props,
PipelineConfiguration pipe,
CharacterMapExpander characterMapExpander,
ProxyReceiver normalizer) throws XPathException {
return super.createXMLSerializer(emitter, props, pipe, characterMapExpander, normalizer);
}
@Override
protected Emitter newXMLEmitter() {
return new TracingOutputter(dbg.getEventQueue(), super.newXMLEmitter());
}
});
controller.getConfiguration().setDebugger(new Debugger() {
public SlotManager makeSlotManager() {
return new SlotManager() {
@Override
public int allocateSlotNumber(StructuredQName qName) {
System.out.println("qName = " + qName);
return super.allocateSlotNumber(qName);
}
};
}
});
return true;
}
return false;
}
示例2: call
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
try {
String json = ((StringValue) arguments[0].head()).getStringValue();
if (StringUtils.isBlank(json)) {
return EmptySequence.getInstance();
}
XMLInputFactory factory = new JsonXMLInputFactory();
XMLStreamReader reader = factory.createXMLStreamReader(new StringReader(json));
StAXSource source = new StAXSource(reader);
Configuration config = context.getConfiguration();
PipelineConfiguration pipe = config.makePipelineConfiguration();
pipe.getParseOptions().getParserFeatures().remove("http://apache.org/xml/features/xinclude");
TinyBuilder builder = new TinyBuilder(pipe);
SerializerFactory sf = config.getSerializerFactory();
Receiver receiver = sf.getReceiver(builder, pipe, new Properties());
NamespaceReducer reducer = new NamespaceReducer(receiver);
ParseOptions options = pipe.getParseOptions();
options.setContinueAfterValidationErrors(true);
Sender.send(source, reducer, options);
return builder.getCurrentRoot();
} catch (Exception e) {
throw new XPathException("Error parsing JSON string", e);
}
}
示例3: transcode
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
public <T extends Result> T transcode(SdcctXsltExecutable xsltExec, Source src, T result, @Nullable HtmlTranscodeOptions opts) throws Exception {
if (src instanceof StreamSource) {
StaxToEventBridge srcEventIterator = new StaxToEventBridge();
srcEventIterator.setPipelineConfiguration(this.config.makePipelineConfiguration());
srcEventIterator.setXMLStreamReader(this.xmlInFactory.createXMLStreamReader(src));
src = new SdcctPullEventSource(SdcctTransformUtils.getPublicId(src), src.getSystemId(), srcEventIterator);
}
// noinspection ConstantConditions
Receiver receiver =
((opts = this.defaultTranscodeOpts.clone().merge(opts)).getOption(ContentCodecOptions.PRETTY) ? this.prettySerializer : this.serializer)
.getReceiver(this.config, this.config.makePipelineConfiguration(), result, null, null);
DynamicXsltOptions xsltOpts = new DynamicXsltOptionsImpl();
xsltOpts.setSource(src);
xsltOpts.setDestination(new AugmentedDestination(new ReceiverDestination<>(receiver)).addFilters(HtmlCdataXmlFilter::new));
xsltOpts.setVariables(opts.getVariables());
xsltExec.load(xsltOpts).transform();
return result;
}
示例4: parse
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
@Override
public void parse(InputSource input) throws IOException, SAXException {
final ContentHandlerProxy chp = new ContentHandlerProxy();
chp.setLexicalHandler(lexicalHandler);
chp.setUnderlyingContentHandler(handler);
this.source.addFilter(new FilterFactory() {
@Override
public ProxyReceiver makeFilter(Receiver arg0) {
return new ContentHandlerProxyReceiver(chp, arg0);
}
});
try {
config.buildDocument(source);
} catch (XPathException e) {
throw new SAXException(e);
}
}
示例5: getReceiver
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
@Override
public Receiver getReceiver(Result result, PipelineConfiguration pipelineConfig, Properties outProps, @Nullable CharacterMapIndex charMapIndex)
throws XPathException {
int indentSpaces = config.getInteger(outProps, SaxonOutputKeys.INDENT_SPACES, -1);
boolean indent = (this.config.getBoolean(outProps, OutputKeys.INDENT) && (indentSpaces > 0));
outProps.setProperty(OutputKeys.INDENT, CrigttConfigurationValues.NO);
Receiver receiver = super.getReceiver(result, pipelineConfig, outProps, charMapIndex);
if (indent) {
(receiver = new ReceiverToXMLStreamWriter(new PrettyPrintXMLStreamWriter(new StreamWriterToReceiver(receiver), indentSpaces)))
.setPipelineConfiguration(pipelineConfig);
}
return receiver;
}
示例6: getNodeNum
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
/**
* Retrieves the current node number in the build. Indexer uses this to
* record node numbers in text chunks.
*
* @param inBuilder The builder gotten from begin()
* @return The current node number.
*/
public int getNodeNum(Receiver inBuilder) {
HackedTinyBuilder builder = (HackedTinyBuilder)inBuilder;
tree = builder.getTree();
// Don't count the stopper at the end of the tiny tree.
int nNodes = tree.getNumberOfNodes();
while (nNodes > 0 && tree.getNodeKind(nNodes-1) == Type.STOPPER)
nNodes--;
return nNodes;
}
示例7: call
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
@Override
public ZeroOrOne<NodeInfo> call(XPathContext context, Sequence[] arguments) throws XPathException {
String xml = ((StringValue) arguments[0].head()).getStringValue();
try {
Controller controller = context.getController();
if (controller == null) {
throw new XPathException("parse() function is not available in this environment");
}
Configuration configuration = controller.getConfiguration();
StringReader sr = new StringReader(xml);
InputSource is = new InputSource(sr);
//is.setSystemId(baseURI);
Source source = new SAXSource(is);
//source.setSystemId(baseURI);
Builder b = TreeModel.TINY_TREE.makeBuilder(controller.makePipelineConfiguration());
Receiver s = b;
ParseOptions options = new ParseOptions();
options.setStripSpace(Whitespace.XSLT);
options.setErrorListener(context.getConfiguration().getErrorListener());
if (controller.getExecutable().stripsInputTypeAnnotations()) {
s = configuration.getAnnotationStripper(s);
}
s.setPipelineConfiguration(b.getPipelineConfiguration());
Sender.send(source, s, options);
TinyDocumentImpl node = (TinyDocumentImpl) b.getCurrentRoot();
// node.setBaseURI(baseURI);
node.setSystemId(null);
b.reset();
return new ZeroOrOne<NodeInfo>((NodeInfo)node);
} catch (XPathException err) {
throw new XPathException("First argument to parse is not a well-formed and namespace-well-formed XML document. XML parser reported: " + err.getMessage(), "FODC0006");
}
}
示例8: AbstractSdcctCdataXmlFilter
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
protected AbstractSdcctCdataXmlFilter(Receiver nextReceiver) {
super(nextReceiver);
Receiver receiver = this.nextReceiver;
while (!(receiver instanceof ReceiverToXMLStreamWriter)) {
receiver = ((receiver instanceof ComplexContentOutputter)
? ((ComplexContentOutputter) receiver).getReceiver() : ((ProxyReceiver) receiver).getUnderlyingReceiver());
}
this.writer = Stax2WriterAdapter.wrapIfNecessary(((ReceiverToXMLStreamWriter) receiver).getXMLStreamWriter());
}
示例9: getReceiver
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
@Override
public Receiver getReceiver(Configuration config) throws SaxonApiException {
Receiver receiver = this.delegate.getReceiver(config);
if (this.hasFilters()) {
for (int a = (this.filters.size() - 1); a >= 0; a--) {
receiver = this.filters.get(a).makeFilter(receiver);
}
}
return receiver;
}
示例10: HtmlCdataXmlFilter
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
public HtmlCdataXmlFilter(Receiver nextReceiver) {
super(nextReceiver);
}
示例11: ContentHandlerProxyReceiver
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
public ContentHandlerProxyReceiver(Receiver receiver, Receiver next) {
super(next);
this.reciever = receiver;
this.reciever.setPipelineConfiguration(next.getPipelineConfiguration());
}
示例12: serializeToResult
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
public <T extends Result> T serializeToResult(Source src, T result, Properties outProps) throws SaxonApiException {
CrigttConfiguration config = this.getProcessor().getUnderlyingConfiguration();
ParseOptions parseOpts = config.getParseOptions();
try {
Receiver receiver = config.getSerializerFactory().getReceiver(result, config.makePipelineConfiguration(), outProps);
if (src instanceof AugmentedSource) {
AugmentedSource augmentedSrc = ((AugmentedSource) src);
parseOpts = augmentedSrc.getParseOptions();
List<FilterFactory> srcFilters = augmentedSrc.getFilters();
if (!CollectionUtils.isEmpty(srcFilters)) {
for (int a = (srcFilters.size() - 1); a >= 0; a--) {
receiver = srcFilters.get(a).makeFilter(receiver);
}
srcFilters.clear();
}
}
Sender.send(src, receiver, parseOpts);
receiver.close();
} catch (XPathException e) {
throw new SaxonApiException(e);
}
return result;
}
示例13: createFilteredReceiver
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
/**
* Makes a Saxon Receiver that will transparently add a session IDs
* to URLs if they match the servlet URL, or other patterns configured
* in the conf file.
*
* @param trans The transformer that will do the work
* @param req The servlet request being processed
* @param res The servlet response to output to
* @return A Receiver suitable for the target of the transform
*/
public Result createFilteredReceiver(Transformer trans,
HttpServletRequest req,
HttpServletResponse res)
throws XPathException, IOException
{
StreamResult stream = new StreamResult(res.getOutputStream());
TextConfig config = getConfig();
if (config.trackSessions && config.sessionEncodeURLPattern != null)
{
// NOTE: It's a good thing we're no longer defaulting to doing this, because it
// effectively prevents Saxon from being able to switch the xsl:output parameters
// during the transformation (such as in response to an xsl:result-document
// element.)
//
Controller controller = (Controller)trans;
SerializerFactory factory = controller.getConfiguration().getSerializerFactory();
Receiver target = factory.getReceiver(stream,
controller.makePipelineConfiguration(),
trans.getOutputProperties());
return new SessionURLRewriter(target,
config.sessionEncodeURLPattern,
req,
res);
}
else
{
// Return a StreamResult, not a Receiver. This allows Saxon to change the output
// parameters during the transformation (e.g. in response to xsl:result-document).
return stream;
}
}
示例14: SessionURLRewriter
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
/**
* Construct the URL rewriter, recording a reference to the receiver
* that will get the data, and the HTTP servlet response we'll use to
* get session info and to rewrite URLs.
*/
SessionURLRewriter(Receiver underlyingReceiver, Pattern encodeURLPattern,
HttpServletRequest httpRequest,
HttpServletResponse httpResponse)
{
setUnderlyingReceiver(underlyingReceiver);
this.encodeURLPattern = encodeURLPattern;
this.httpRequest = httpRequest;
this.httpResponse = httpResponse;
}
示例15: sendNamespaceDeclarations
import net.sf.saxon.event.Receiver; //导入依赖的package包/类
/**
* Output all namespace nodes associated with this element.
* @param out The relevant outputter
* @param includeAncestors True if namespaces associated with ancestor
*/
public void sendNamespaceDeclarations(Receiver out, boolean includeAncestors)
throws XPathException
{
if (!document.usesNamespaces) {
return;
}
int ns = nameSpace;
if (ns > 0)
{
while (ns < document.numberOfNamespaces &&
document.namespaceParent[ns] == nodeNum)
{
int nscode = document.namespaceCode[ns];
out.namespace(nscode, 0);
ns++;
}
}
// now add the namespaces defined on the ancestor nodes. We rely on the receiver
// to eliminate multiple declarations of the same prefix
if (includeAncestors && document.isUsingNamespaces())
{
NodeInfo parent = getParent();
if (parent != null) {
parent.sendNamespaceDeclarations(out, true);
}
// terminates when the parent is a root node
}
}