How can I start a new "record" and then nest tags in that record?


but I'm getting output like:

<xml>
  <record>
      if (matches($line, "[0-9]"))
      then <data>people</data>
      else <name>people</name>
  </record>
  <record>
      if (matches($line, "[0-9]"))
      then <data>joe</data>
      else <name>joe</name>
  </record>
..

wheras I just want output like:

<record>
  <name>joe</name>
  <data>123</data>
</record>


the query:

xquery version "3.0";

<xml>
{
for $line in db:open("foo.txt")//text()
return
        <record>
      if (matches($line, "[0-9]"))
      then <data>{$line}</data>
      else <name>{$line}</name>
        </record>
}
</xml>



I think it's a matter of using the () and {} correctly. Pardon, yes, I'm literally reading a book on this, still trying to understand the syntax.



thanks,

Thufir

Reply via email to