本文整理汇总了Java中net.sf.saxon.s9api.Serializer.setOutputProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Serializer.setOutputProperty方法的具体用法?Java Serializer.setOutputProperty怎么用?Java Serializer.setOutputProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.saxon.s9api.Serializer
的用法示例。
在下文中一共展示了Serializer.setOutputProperty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDestination
import net.sf.saxon.s9api.Serializer; //导入方法依赖的package包/类
private Destination getDestination(WebApp webApp, Destination destination, PipelineStep step) {
if (webApp.getDevelopmentMode() && step.getLog()) {
StringWriter sw = new StringWriter();
sw.write("----------\n");
sw.write("OUTPUT OF STEP: \"" + step.getName() + "\":\n");
Serializer debugSerializer = webApp.getProcessor().newSerializer(new ProxyWriter(sw) {
@Override
public void flush() throws IOException {
logger.debug(out.toString());
}
});
debugSerializer.setOutputProperty(Serializer.Property.METHOD, "xml");
debugSerializer.setOutputProperty(Serializer.Property.INDENT, "yes");
if (destination instanceof XdmDestination) {
destination = new TeeSourceDestination((XdmDestination) destination, debugSerializer);
} else {
destination = new TeeDestination(destination, debugSerializer);
}
}
return destination;
}
示例2: processInlineEntry
import net.sf.saxon.s9api.Serializer; //导入方法依赖的package包/类
private void processInlineEntry(String uri, String localName, String qName, Attributes attributes) throws Exception {
String name = attributes.getValue("", "name");
if (name == null) {
throw new SAXException("No attribute \"name\" specified on inline-entry element");
}
Serializer serializer = webApp.getProcessor().newSerializer(this.zos);
for (int i=0; i<attributes.getLength(); i++) {
String n = attributes.getLocalName(i);
if (n.equals("name")) {
continue;
}
String value = attributes.getValue(i);
if (n.equals(OutputKeys.CDATA_SECTION_ELEMENTS)) {
value = value.replaceAll("\\{\\}", "{''}");
}
serializer.setOutputProperty(Property.get(n), value);
}
ZipEntry entry = new ZipEntry(name);
zos.putNextEntry(entry);
this.xsw = serializer.getXMLStreamWriter();
this.serializingHandler = new ContentHandlerToXMLStreamWriter(xsw);
}
示例3: getSerializer
import net.sf.saxon.s9api.Serializer; //导入方法依赖的package包/类
/**
* Return indenting XML serializer
*
* @return Saxon serializer
*/
private static Serializer getSerializer() {
Configuration config = new Configuration();
Processor processor = new Processor(config);
Serializer s = processor.newSerializer();
s.setOutputProperty(Property.METHOD, "xml");
s.setOutputProperty(Property.ENCODING, "utf-8");
s.setOutputProperty(Property.INDENT, "yes");
return s;
}
示例4: getOutput
import net.sf.saxon.s9api.Serializer; //导入方法依赖的package包/类
/** Retrieves the output for a given xslt transformer.
* @param xsltTransformer the {@link XsltTransformer} that will receive the output
* @return the output as a {@link ByteArrayOutputStream}
*/
public ByteArrayOutputStream getOutput(final XsltTransformer xsltTransformer) {
Serializer serializer = serializerFactory.createSerializer();
serializer.setOutputProperty(Serializer.Property.METHOD, "xml");
serializer.setOutputProperty(Serializer.Property.INDENT, "no");
ByteArrayOutputStream output = byteArrayOutputStreamFactory.createByteArrayOutputStream();
serializer.setOutputStream(output);
xsltTransformer.setDestination(serializer);
return output;
}
示例5: createSerializer
import net.sf.saxon.s9api.Serializer; //导入方法依赖的package包/类
private static Serializer createSerializer(final OutputStream out) {
Serializer serializer = new Serializer();
serializer.setOutputProperty(Serializer.Property.METHOD, "xml");
serializer.setOutputProperty(Serializer.Property.ENCODING, "UTF-8");
serializer.setOutputProperty(Serializer.Property.INDENT, "yes");
serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes");
serializer.setOutputStream(out);
return serializer;
}
示例6: doFilter
import net.sf.saxon.s9api.Serializer; //导入方法依赖的package包/类
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
WebApp webApp = null;
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
try {
webApp = (WebApp) request.getAttribute(Definitions.ATTRNAME_WEBAPP);
RequestSerializer requestSerializer = new RequestSerializer(req, webApp);
try {
NodeInfo requestNodeInfo = requestSerializer.serializeToNodeInfo();
request.setAttribute(Definitions.ATTRNAME_REQUESTXML, requestNodeInfo);
if (webApp.getDevelopmentMode()) {
StringWriter sw = new StringWriter();
try {
Serializer ser = webApp.getProcessor().newSerializer(sw);
ser.setOutputProperty(Serializer.Property.INDENT, "yes");
ser.serializeNode(new XdmNode(requestNodeInfo));
logger.debug("----------\nREQUEST XML:" + lineSeparator + sw.toString());
} finally {
sw.close();
}
}
chain.doFilter(request, response);
} finally {
requestSerializer.close();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
if (webApp != null && webApp.getDevelopmentMode()) {
resp.setContentType("text/plain; charset=UTF-8");
e.printStackTrace(new PrintStream(resp.getOutputStream()));
} else if (!resp.isCommitted()) {
resp.resetBuffer();
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
resp.setContentType("text/html; charset=UTF-8");
Writer w = new OutputStreamWriter(resp.getOutputStream(), "UTF-8");
w.write("<html><body><h1>Internal Server Error</h1></body></html>");
}
}
}
示例7: prepareSerializer
import net.sf.saxon.s9api.Serializer; //导入方法依赖的package包/类
private Serializer prepareSerializer() {
Serializer out = processor.newSerializer(output);
out.setOutputProperty(Serializer.Property.METHOD, "xml");
out.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes");
return out;
}