# -*- ruby -*-
#
# Select data with [pos,n], [beg..end], [pos].
#

require 'xtemplate'

data ={
  'links' => [
    {'url' => "url1", 'name' => "anchor1"},
    {'url' => "url2", 'name' => "anchor2"},
    {'url' => "url3", 'name' => "anchor3"},
  ]
}

text = <<EOF
<?xml version="1.0" encoding="EUC-JP"?>
<html>
<body>
  <ul>
    <li id="links[0,2]/url"></li>
  </ul>
  <ul>
    <li id="links[1..2]/url"></li>
  </ul>
  <ul>
    <li id="links[2]/url"></li>
  </ul>
</body>
</html>
EOF

t = XTemplate::XMLTemplate.new(text)
print(t.expand(data))
