Indexes stag nodes (XML Elements) in a simple relational db structure - keyed by ID with an XML Blob as a value

Imagine you have a very large file of data, in a stag compatible format such as XML. You want to index all the elements of type person; each person can be uniquely identified by social_security_no, which is a direct subnode of person

The first thing to do is to build the index file, which will be stored in the database mydb

stag-ir.pl -r person -k social_security_no -d Pg:mydb myrecords.xml

You can then use the index "person-idx" to retrieve person nodes by their social security number

stag-ir.pl -d Pg:mydb -q 999-9999-9999 > some-person.xml

You can export using different stag formats

stag-ir.pl -d Pg:mydb -q 999-9999-9999 -w sxpr > some-person.xml

You can retrieve multiple nodes (although these need to be rooted to make a valid file)

note that if you are using -insertonly, and you are using transactions, and the input file contains an ID already in the database, then the transaction will fail because this script will try and insert a duplicate ID