Query-Oriented Model for XML 0.1 Alpha1 review
Download
|
|
Query-Oriented Model for XML is a lightweight XML processing framework for Java that promotes the use of XPath instead of Java code for consuming XML.
The resulting code from Query-Oriented Model for XML, is simple and expressive with no meaningless objects and no meaningless parameters - just pure business code.
Here's a sample of usage (from a testcase -- here's the used XML document):
public class BigTest extends TestCase {
public static final String[] CONTEXT = {"c urn:catalog", "n urn:name"};
@QUseContext("CONTEXT") // Use the namespace context specified by the CONTEXT field.
public void test() {
InputStream xml = QomTestResources.getTestXml("catalog.xml"); // Get the source.
QLocation root = new QBuilder().build(xml); // Build the root location.
// Test a deep query.
Assert.assertEquals("Harold", root.value("//c:maintainer/n:name[n:first_name = 'Elliotte']/n:last_name"));
QLocation[] composers = root.locateAll("c:composer"); // Test a multi-query.
Assert.assertEquals(4, composers.length);
String[] names = {"Julie", "Margaret", "Beth", "Linda"};
for (int i = 0; i < composers.length; ++i) {
Assert.assertEquals(names[i], composers[i].value("n:name/n:first_name")); // Test relative queries.
}
}
}
Query-Oriented Model for XML 0.1 Alpha1 search tags