5.11. NodeModel Example
The following example shows you how to configure the NodeModel element:
<?xml version="1.0"?> <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.3.xsd" xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd"> <!-- Extract and decode data from the message. Used in the freemarker template (below). --> <jb:bean beanId="order" class="java.util.Hashtable" createOnElement="order"> <jb:value property="orderId" decoder="Integer" data="order/@id"/> <jb:value property="customerNumber" decoder="Long" data="header/customer/@number"/> <jb:value property="customerName" data="header/customer"/> <jb:wiring property="orderItem" beanIdRef="orderItem"/> </jb:bean> <jb:bean beanId="orderItem" class="java.util.Hashtable" createOnElement="order-item"> <jb:value property="itemId" decoder="Integer" data="order-item/@id"/> <jb:value property="productId" decoder="Long" data="order-item/product"/> <jb:value property="quantity" decoder="Integer" data="order-item/quantity"/> <jb:value property="price" decoder="Double" data="order-item/price"/> </jb:bean> <ftl:freemarker applyOnElement="order-item"> <ftl:template><!--<orderitem id="${order.orderItem.itemId}" order="${order.orderId}"> <customer> <name>${order.customerName}</name> <number>${order.customerNumber?c}</number> </customer> <details> <productId>${order.orderItem.productId}</productId> <quantity>${order.orderItem.quantity}</quantity> <price>${order.orderItem.price}</price> </details> </orderitem>--> </ftl:template> </ftl:freemarker> </smooks-resource-list>
Note
An extended example can be seen at http://www.smooks.org/mediawiki/index.php?title=Smooks_v1.3_Examples.