- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.xembly.Xembler
类的一些代码示例,展示了Xembler
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Xembler
类的具体详情如下:
包路径:org.xembly.Xembler
类名称:Xembler
[英]Processor of Xembly directives, main entry point to the package.
For example, to modify a DOM document:
Document dom = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().newDocument();
dom.appendChild(dom.createElement("root"));
new Xembler(
new Directives()
.xpath("/root")
.addIfAbsent("employees")
.add("employee")
.attr("id", 6564)
).apply(dom);
You can also convert your Xembly directives directly to XML document:
String xml = new Xembler(
new Directives()
.xpath("/root")
.addIfAbsent("employees")
.add("employee")
.attr("id", 6564)
).xml("root");
Since version 0.18 you can convert directives to XML without a necessity to catch checked exceptions. Use *Quietly() methods for that: #xmlQuietly(), #domQuietly(), and #applyQuietly(org.w3c.dom.Node).
[中]Xembly指令的处理器,包的主要入口点。
例如,要修改DOM文档:
Document dom = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().newDocument();
dom.appendChild(dom.createElement("root"));
new Xembler(
new Directives()
.xpath("/root")
.addIfAbsent("employees")
.add("employee")
.attr("id", 6564)
).apply(dom);
还可以将Xembly指令直接转换为XML文档:
String xml = new Xembler(
new Directives()
.xpath("/root")
.addIfAbsent("employees")
.add("employee")
.attr("id", 6564)
).xml("root");
自版本0.18以来,您可以将指令转换为XML,而无需捕获已检查的异常。为此使用*quilly()方法:#xmlquilly()、#domquilly()和#applyquilly(org.w3c.dom.Node)。
代码示例来源:origin: jcabi/jcabi-github
@Override
public void apply(
final Iterable<Directive> dirs
) throws IOException {
synchronized (this.name) {
FileUtils.write(
new File(this.name),
new XMLDocument(
new Xembler(dirs).applyQuietly(this.xml().node())
).toString(),
StandardCharsets.UTF_8
);
}
}
@Override
代码示例来源:origin: com.jcabi.incubator/xembly
/**
* Convert to XML document, without checked exceptions.
* @return XML document
* @since 0.18
*/
public String xmlQuietly() {
try {
return this.xml();
} catch (final ImpossibleModificationException ex) {
throw new IllegalStateException(
String.format(
"failed to build XML quietly: %s",
this.directives
),
ex
);
}
}
代码示例来源:origin: yegor256/xembly
/**
* Apply all changes to the document/node, without any checked exceptions.
* @param dom DOM document/node
* @return The same document/node
* @since 0.18
*/
public Node applyQuietly(final Node dom) {
try {
return this.apply(dom);
} catch (final ImpossibleModificationException ex) {
throw new IllegalArgumentException(
String.format(
"failed to apply to DOM quietly: %s",
this.directives
),
ex
);
}
}
代码示例来源:origin: yegor256/s3auth
new XMLDocument(new Xembler(dirs).xml())
).toString().getBytes(Charsets.UTF_8);
} catch (final ImpossibleModificationException ex) {
代码示例来源:origin: etsy/arbiter
new Xembler(directives).apply(xmlDoc);
} catch (ImpossibleModificationException e) {
throw new RuntimeException(e);
代码示例来源:origin: yegor256/jpeek
new Xembler(new Index(this.output)).xmlQuietly()
App.xsl("badge.xsl").transform(
new XMLDocument(
new Xembler(
new Directives().add("badge").set(
index.xpath("/index/@score").get(0)
).attr("style", "round")
).xmlQuietly()
App.xsl("matrix-post.xsl").transform(
new XMLDocument(
new Xembler(new Matrix(this.output)).xmlQuietly()
代码示例来源:origin: com.jcabi.incubator/xembly
/**
* Apply all changes to an empty DOM, without checked exceptions.
* @return DOM created
* @since 0.18
*/
public Document domQuietly() {
try {
return this.dom();
} catch (final ImpossibleModificationException ex) {
throw new IllegalStateException(
String.format(
"failed to create DOM quietly: %s",
this.directives
),
ex
);
}
}
代码示例来源:origin: yegor256/s3auth
new XMLDocument(new Xembler(dirs).xml())
).toString().getBytes(Charsets.UTF_8);
} catch (final ImpossibleModificationException ex) {
代码示例来源:origin: yegor256/jpeek
final XML xml = new StrictXML(
new XMLDocument(
new Xembler(
new Directives()
.add("skeleton")
).xmlQuietly()
),
Skeleton.SCHEMA
代码示例来源:origin: yegor256/xembly
/**
* Apply all changes to an empty DOM, without checked exceptions.
* @return DOM created
* @since 0.18
*/
public Document domQuietly() {
try {
return this.dom();
} catch (final ImpossibleModificationException ex) {
throw new IllegalStateException(
String.format(
"failed to create DOM quietly: %s",
this.directives
),
ex
);
}
}
代码示例来源:origin: yegor256/takes
/**
* Render source as XML.
* @param dom DOM node to build upon
* @param src Source
* @return XML
* @throws IOException If fails
*/
private static InputStream render(final Node dom,
final XeSource src) throws IOException {
final Node copy = cloneNode(dom);
final ByteArrayOutputStream baos =
new ByteArrayOutputStream();
final Node node = new Xembler(src.toXembly()).applyQuietly(copy);
try {
TransformerFactory.newInstance().newTransformer().transform(
new DOMSource(node),
new StreamResult(
new Utf8OutputStreamWriter(baos)
)
);
} catch (final TransformerException ex) {
throw new IllegalStateException(ex);
}
return new ByteArrayInputStream(baos.toByteArray());
}
代码示例来源:origin: com.rempl/rempl
@Override
public void save(final OutputStream output) throws IOException {
final Directives dirs = new Directives().add("xmi");
for (final Instance instance : this.instances) {
dirs.add("instance").add("slots");
for (final String slot : instance.slots()) {
dirs.add("slot").add("key").set(slot).up()
.add("value").set(instance.get(slot)).up().up();
}
dirs.up().add("name").set(instance.name()).up()
.add("type").set(instance.type()).up().up();
}
try {
IOUtils.write(
new Xembler(dirs).xml().toString().getBytes(Charsets.UTF_8),
output
);
} catch (final ImpossibleModificationException ex) {
throw new IllegalStateException(ex);
}
}
代码示例来源:origin: yegor256/xembly
/**
* Convert to XML document, without checked exceptions.
* @return XML document
* @since 0.18
*/
public String xmlQuietly() {
try {
return this.xml();
} catch (final ImpossibleModificationException ex) {
throw new IllegalStateException(
String.format(
"failed to build XML quietly: %s",
this.directives
),
ex
);
}
}
代码示例来源:origin: com.jcabi.incubator/xembly
/**
* Apply all changes to the document/node, without any checked exceptions.
* @param dom DOM document/node
* @return The same document/node
* @since 0.18
*/
public Node applyQuietly(final Node dom) {
try {
return this.apply(dom);
} catch (final ImpossibleModificationException ex) {
throw new IllegalArgumentException(
String.format(
"failed to apply to DOM quietly: %s",
this.directives
),
ex
);
}
}
代码示例来源:origin: com.jcabi.incubator/xembly
try {
transformer.transform(
new DOMSource(this.dom()),
new StreamResult(writer)
);
代码示例来源:origin: org.takes/takes
/**
* Render source as XML.
* @param dom DOM node to build upon
* @param src Source
* @return XML
* @throws IOException If fails
*/
private static InputStream render(final Node dom,
final XeSource src) throws IOException {
final Node copy = cloneNode(dom);
final ByteArrayOutputStream baos =
new ByteArrayOutputStream();
final Node node = new Xembler(src.toXembly()).applyQuietly(copy);
try {
TransformerFactory.newInstance().newTransformer().transform(
new DOMSource(node),
new StreamResult(
new Utf8OutputStreamWriter(baos)
)
);
} catch (final TransformerException ex) {
throw new IllegalStateException(ex);
}
return new ByteArrayInputStream(baos.toByteArray());
}
代码示例来源:origin: com.jcabi.incubator/xembly
/**
* Apply all changes to an empty DOM.
* @return DOM created
* @throws ImpossibleModificationException If can't modify
* @since 0.9
*/
public Document dom() throws ImpossibleModificationException {
final Document dom;
try {
dom = Xembler.BFACTORY.newDocumentBuilder().newDocument();
} catch (final ParserConfigurationException ex) {
throw new IllegalStateException(
String.format(
"failed to obtain a new DOM document from %s",
Xembler.BFACTORY.getClass().getCanonicalName()
),
ex
);
}
this.apply(dom);
return dom;
}
代码示例来源:origin: yegor256/xembly
try {
transformer.transform(
new DOMSource(this.dom()),
new StreamResult(writer)
);
代码示例来源:origin: yegor256/jpeek
new Xembler(
new Directives()
.xpath("/metric")
.add("defects")
.set(Double.toString(defects / total)).up()
).applyQuietly(xml.node())
);
代码示例来源:origin: yegor256/xembly
/**
* Apply all changes to an empty DOM.
* @return DOM created
* @throws ImpossibleModificationException If can't modify
* @since 0.9
*/
public Document dom() throws ImpossibleModificationException {
final Document dom;
try {
dom = Xembler.BFACTORY.newDocumentBuilder().newDocument();
} catch (final ParserConfigurationException ex) {
throw new IllegalStateException(
String.format(
"failed to obtain a new DOM document from %s",
Xembler.BFACTORY.getClass().getCanonicalName()
),
ex
);
}
this.apply(dom);
return dom;
}
本文整理了Java中org.xembly.Xembler.apply()方法的一些代码示例,展示了Xembler.apply()的具体用法。这些代码示例主要来源于Github/Stackoverflo
本文整理了Java中org.xembly.Xembler.xml()方法的一些代码示例,展示了Xembler.xml()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Ma
本文整理了Java中org.xembly.Xembler.applyQuietly()方法的一些代码示例,展示了Xembler.applyQuietly()的具体用法。这些代码示例主要来源于Githu
本文整理了Java中org.xembly.Xembler.()方法的一些代码示例,展示了Xembler.()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台
我是一名优秀的程序员,十分优秀!