Using The Repeated Region builder

I recently encountered a case where I needed to display some repeating xml data that was embedded in a larger xml structure, something that the data page builder doesn't do well. So I decided to take a look at the repeated region builder, and found out that as with many builders, the correct inputs aren't so easy to figure out.

The data in a variable builder (varData) :
 <dsixe>  
<contact>
<name></name>
<phone></phone>
</contact>
<order>
<item>
<id>1234</id>
<descr>Item one</descr>
<upc>DC88776</upc>
</item>
<item>
<id>3456</id>
<descr>Item two</descr>
<upc>DC88773</upc>
</item>
<item>
<id>3458</id>
<descr>Item three</descr>
<upc>DC88774</upc>
</item>
</order>
</dsixe>

Note that <contact> is a sibling element of <order>, but we're not interested in that. What we want is just a list of orders with the ID hyperlinked to a URL which uses the UPC code as a parameter.

Page builder contents:
 <html>  
<head><title>Default Test Page</title></head>
<body>
Orders:<br>
<table>
<tr name="repeatRow">
<td><span name="id"/></td>
<td name="descr"/>
</tr>
</table>
</body>
</html>

Produces:
Orders: 





1234 Item one
3456 Item two
3458 Item three

The repeated region builder is designed to handle this exact scenario, the difficulty comes in defining the correct input values for the builder.


Note that the source data input field points to varData/dsixe/order and not varData/dsixe/order/item. The key piece of information here is the loop variable name (dsixeLoopVar) which is used in other builders to refer to values which are repeated. I think the reason this builder is difficult to use is due to the fact that this variable name doesn't show up as expanded in the variable pickers, it has to be manually typed in.
Also note how the page location repeatRow is a table row and identifies what chunk of HTML will be repeated.

Let's add a text builder to display the descr element:


In this case I was able to select ${Variables/dsixeLoopVar} from the picker and then type /item/descr on the end.

Hope someone finds this useful!

Comments

Popular posts from this blog

How to Open QR Codes

Jim Henson predicted the end of the world

Mega Giveaway! (Today only!!!)