<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Home</title><link>https://sourceforge.net/p/generationxml/wiki/Home/</link><description>Recent changes to Home</description><atom:link href="https://sourceforge.net/p/generationxml/wiki/Home/feed" rel="self"/><language>en</language><lastBuildDate>Wed, 09 Jul 2014 20:30:43 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/generationxml/wiki/Home/feed" rel="self" type="application/rss+xml"/><item><title>Home modified by teknopaul</title><link>https://sourceforge.net/p/generationxml/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v3
+++ v4
@@ -138,7 +138,7 @@

 # Related Projects

-* jquery.xgen.js - A jQuery plugin providing xGenPaths witha single `create()`    º+ººº method
+* jquery.xgen.js - A jQuery plugin providing xGenPaths witha single `create()` method
 * xgenjs - xGenPaths for nodejs.

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">teknopaul</dc:creator><pubDate>Wed, 09 Jul 2014 20:30:43 -0000</pubDate><guid>https://sourceforge.netcb37389db53dc76b9e98fb8dfae828ab793f03ad</guid></item><item><title>Home modified by teknopaul</title><link>https://sourceforge.net/p/generationxml/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -1,4 +1,6 @@
 # Generation-X
+
+A Java xGenPath implementation.

 Programatic XML generation without templates.

@@ -18,9 +20,7 @@

 # Example

-This example code creates a bootstrap HTML page. Generation-X is perhaps better suited to genreating
-XML but the HTML schema should be familiar so it should be easy to see from this example what
-the intention of the code is.
+This example code creates a bootstrap HTML page. Generation-X is perhaps better suited to genreating XML but the HTML schema should be familiar so it should be easy to see from this example what the intention of the code is.
 N.B. _select()_ is using XPaths and _create()_ is useing xGenPaths.

     XGen xGen = XGenFactory.newInstance();
@@ -116,7 +116,7 @@

 ## Lambdas

-For JDK 7 we dont have lambdas yet but there is an _each()_ method to whet your appetite.
+There is an _each()_ method that looks a bit bulky in JDK7 code but can be a lanbda function in JDK8.

     xGen.newDocument("/xml")
         .create("div/ul/li[3]")
@@ -136,14 +136,9 @@

 LGPL

-# Coming Soon...
+# Related Projects

-Ideas for future development
-
-* Lamda support - need specific Java 8 builds.
-* xGenPath for jQuery - would be cool should be easy to port from Java.
-* xGenPath for nodejs - XML is not favoured in the nodejs community but might help someone.
-* xGenPath for JSON - Should be as useful for generating big JSON blobs as it is for XML.
-* Support for .. parent paths - This would save some xpath lookups, but might be hard to implement.
+* jquery.xgen.js - A jQuery plugin providing xGenPaths witha single `create()`    º+ººº method
+* xgenjs - xGenPaths for nodejs.

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">teknopaul</dc:creator><pubDate>Wed, 09 Jul 2014 20:30:04 -0000</pubDate><guid>https://sourceforge.net1bf67ad15d075c6fe096f35feebf38f89b325298</guid></item><item><title>Home modified by teknopaul</title><link>https://sourceforge.net/p/generationxml/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -1,8 +1,149 @@
-Welcome to your wiki!
+# Generation-X

-This is the default page, edit it as you see fit. To add a new page simply reference it within brackets, e.g.: [SamplePage].
+Programatic XML generation without templates.

-The wiki uses [Markdown](/p/generationxml/wiki/markdown_syntax/) syntax.
+Using the Java org.w3c.dom APIs to create XML docs involves a lot of boiler plate code.

-[[members limit=20]]
-[[download_button]]
+This project implements an XPath like syntax for generating new XML elements.
+
+The following _xGenPath_ will create the expected XML output.
+
+    /html/body/div#container/table.table/tbody/tr[5]
+    
+This is useful for generating XML when a templating system is not a good fit.
+
+# Install
+
+mvn install
+
+# Example
+
+This example code creates a bootstrap HTML page. Generation-X is perhaps better suited to genreating
+XML but the HTML schema should be familiar so it should be easy to see from this example what
+the intention of the code is.
+N.B. _select()_ is using XPaths and _create()_ is useing xGenPaths.
+
+    XGen xGen = XGenFactory.newInstance();
+    xGen.setOutputMethod("html");
+       
+    xGen.newDocument("/html{lang=en}/head/title").setTextContent(TITLE);
+       
+    xGen.select("//head").create("link{rel=stylesheet}")
+        .setAttribute("type", "text/css")
+        .setAttribute("href", "http://maxcdn.bootstrapcdn.com/bootswatch/3.1.1/slate/bootstrap.min.css");
+       
+    // Container
+    XGenNodeList container = xGen.select("//html").create("body/div.container");
+
+    // Header
+    container.create("div.row/div.col-md-12/h1.well").setTextContent(TITLE);
+       
+    // Menu
+    container.create("div.row/div.col-md-2/ul.well/li[4]").setTextContent("Menu");
+
+    // jumbotron
+    xGen.select("//div[@class='row'][2]").create("div.col-md-10 jumbotron/h1").setTextContent("Programatic XML Generation");
+       
+    // small footer
+    container.create("div.row/div.text-center/footer/p.small").setTextContent("Copyleft teknopaul");
+       
+    // simplified XML serialization
+    xGen.serialize(new FileOutputStream("./src/test/eg/index.html"));
+
+The above example uses only Generation-X code but behind the scenes the standard Java w3c Dom is used, you can 
+mix and match between the APIs.
+
+    // Create doc with w3c APIs
+    Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+    Element root = doc.createElement("wrapper");
+    doc.appendChild(root);
+
+    // Add a few elements with xGen
+    NodeList nl = XGenFactory.newInstance(doc).create(root, "data/fs/files/file[5]");
+
+    // Carry on with w3c
+    for( int i = 0 ; i &lt; nl.getLength(); i++) {
+        nl.item(i).setTextContent(getFile(i));
+    }
+
+    // Print with xGen
+    XGenFactory.newInstance(doc).serialize(System.out);
+
+    // Or print with Java APIs
+    DOMSource domSource = new DOMSource(doc);
+    TransformerFactory factory = TransformerFactory.newInstance();
+    factory.setAttribute("indent-number", "2");
+    Transformer serializer = factory.newTransformer();
+    if (serializer.getClass().getName().contains("org.apache")) {
+        serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
+    }
+    serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+    serializer.setOutputProperty(OutputKeys.INDENT, "yes");
+    serializer.transform(domSource, new StreamResult(System.out));
+
+# XGenNodeList
+
+The XGen _select()_ and _create()_ methods return a w3c compatible NodeList but the object returned has some handy features.
+
+## XGenNodeList mutators
+
+XGenNodeList has mutator methods that affect all the elements in the list.
+
+    xGenNodeList.setTextContent("foo")
+
+will add "foo" to _all_ the elements in the list.  This is similar to jQuery code where all selectors are potentially arrays.
+
+_setTextContent()_ takes a var-args so if you know you have three elements you can write
+
+    xGen.create("/div/ul/li[3]").setTextContent("one", "two", "three");
+
+_setAttribute(name, value)_ also works on all the elements in the list.
+
+as does _appendChild()_ and also _select()_ and _create()_.
+
+## Chaining calls
+
+XGenNodeList methods generally return _this_ so you can chain calls
+
+    XGen xGen = XGenFactory.newInstance();
+    xGen.newDocument("/xml")
+        .create("div/ul/li[3]")
+        .setTextContent("foo")
+        .setAttribute("abc", "123")
+        .create("a/span")
+        .setAttribute("class", "grey");
+    xGen.serialize(System.out);
+
+## Lambdas
+
+For JDK 7 we dont have lambdas yet but there is an _each()_ method to whet your appetite.
+
+    xGen.newDocument("/xml")
+        .create("div/ul/li[3]")
+        .each(new NodeMutator() {
+            public void each(Node node) {
+                ((Element)node).setAttribute("abc", "123");
+                return node;
+           }
+        }); // you can chain more calls here
+
+# Dependencies
+
+None at runtime, JUnit during the build.
+Jar is only a few K at this stage
+
+# Licence
+
+LGPL
+
+# Coming Soon...
+
+Ideas for future development
+
+* Lamda support - need specific Java 8 builds.
+* xGenPath for jQuery - would be cool should be easy to port from Java.
+* xGenPath for nodejs - XML is not favoured in the nodejs community but might help someone.
+* xGenPath for JSON - Should be as useful for generating big JSON blobs as it is for XML.
+* Support for .. parent paths - This would save some xpath lookups, but might be hard to implement.
+
+
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">teknopaul</dc:creator><pubDate>Sat, 21 Jun 2014 21:23:16 -0000</pubDate><guid>https://sourceforge.net101a59dd720ef0d0050c3491ce9268f6690d8c8f</guid></item><item><title>Home modified by teknopaul</title><link>https://sourceforge.net/p/generationxml/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Welcome to your wiki!&lt;/p&gt;
&lt;p&gt;This is the default page, edit it as you see fit. To add a new page simply reference it within brackets, e.g.: &lt;span&gt;[SamplePage]&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The wiki uses &lt;a class="" href="/p/generationxml/wiki/markdown_syntax/"&gt;Markdown&lt;/a&gt; syntax.&lt;/p&gt;
&lt;p&gt;&lt;h6&gt;Project Members:&lt;/h6&gt;
&lt;ul class="md-users-list"&gt;
&lt;li&gt;&lt;a href="/u/teknopaul/"&gt;teknopaul&lt;/a&gt; (admin)&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;&lt;span class="download-button-53a5d736485acd25a5c6d9e6" style="margin-bottom: 1em; display: block;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">teknopaul</dc:creator><pubDate>Sat, 21 Jun 2014 19:04:22 -0000</pubDate><guid>https://sourceforge.netfa9563b62ad40d08d472ace6730557116e7b8eb6</guid></item></channel></rss>