Releases: yegor256/xembly
Fast implementation of root-only XPath
Fast implementation added for XPATH '/root'
directives. Instead of using XPathFactory
we're getting root node directly from DOM.
Performance boost
In this version performance of Xembler
was boosted a bit.
Graceful handling of empty directives
In this version a small bug was fixed, which didn't allow to use empty input in Directives
. Now it's possible, for example:
String xml = new Xembler(new Directives("")).xml("test");
will produce:
<?xml version="1.0" encoding="UTF-8"?>
<test/>
No special treatment of DOM root element
In this version a special treatment of DOM root element is removed. That means that:
- DOM is created without root element
- DOM transformation starts with an empty set of current nodes
For example, this code creates a new DOM with a root element orders
:
String xml = new Xembler(
new Directives()
.add("orders")
.add("order")
.attr("id", "553")
.set("$140.00")
).xml();
PI directive for adding processing instructions
With this new PI
directive you can add processing instructions to the XML document. Besides that, in this release there are two supplementary methods that enable instance generation of XML. For example:
String xml = new Xembler(
new Directives()
.xpath("/")
.pi("xml-stylesheet", "type='text/xsl' href='foo.xsl'")
.xpath("/document")
.add("title")
.set("Hello, world!")
).xml("document");
Will produce:
<?xml version="1.0"?>
<?xml-stylesheet", "type='text/xsl' href='foo.xsl'"?>
<document>
<title>Hello, world!</title>
</document>
Directives#add(Map)
New method add(Map<K,V>)
added to Directives
class. The method allows you to add multiple XML nodes in one operation, for example:
new Directives().xpath("/root").add(
new ArrayMap<String, Object>()
.with("first", 1)
.with("second", "two")
).add("third")
The XML produced will look like:
<root>
<first>1</first>
<second>two</second>
<third/>
</root>
XSET directive
XSET
directive was added to the language. It enables node content changing with a value retrieved in runtime by XPath expression. This directives turns Xembly into a powerful instrument, similar to XSLT. For example, you can increment XML node value:
ADDIF "price";
XPATH "//price";
XSET ". + 500";
The third directive will increment the price by 500
.
All XPath 2.0 functions can be used in the expression.
Bug fix
Strict validation of XML content
Strict validation of XML content added in #13. Any text that violates the restrictions of XML validity (http://www.w3.org/TR/2004/REC-xml11-20040204/#charsets) causes internal XmlContentException
that leads to other corresponding exceptions.
Stable Version
This is the most stable version released since the creation of the project. All directives work in unit tests, including:
ADD
ADDIF
SET
ATTR
XPATH
STRICT
UP
Unit tests cover almost the entire module. Enjoy :)