/xembly

Assembly for XML

Primary LanguageJavaOtherNOASSERTION

Made By Teamed.io DevOps By Rultor.com

Build Status Build status Maven Central

Xembly is an Assembly-like imperative programming language for data manipulation in XML documents. Read this blog post for a more detailed explanation: Xembly, an Assembly for XML.

For example, you have an XML document:

<orders>
  <order id="553">
    <amount>$45.00</amount>
  </order>
</orders>

And you want to change the amount of the order #553 from $45.00 to $140.00. Xembly script would look like:

XPATH "orders/order[@id=553]";
SET "$140.00";

It is much simpler and compact than XSLT or XQuery.

This Java package implements Xembly:

Document document = DocumentBuilderFactory.newInstance()
  .newDocumentBuilder().newDocument();
Iterable<Directive> dirs = new Directives(
  "ADD 'orders'; ADD 'order'; ATTR 'id', '553'; SET '$140.00';"
);
new Xembler(dirs).apply(document);

Since version 0.9 you can directly transform directives to XML:

String xml = new Xembler(
  new Directives()
    .add("root")
    .add("order")
    .attr("id", "553")
    .set("$140.00")
).xml();

How To Contribute

Fork repository, make changes, send us a pull request. We will review your changes and apply them to the master branch shortly, provided they don't violate our quality standards. To avoid frustration, before sending us your pull request please run full Maven build:

$ mvn clean install -Pqulice

Got questions?

If you have questions or general suggestions, don't hesitate to submit a new Github issue.