[OPEN-ILS-DEV] A command to order the MARC XML

Dan Scott dan at coffeecode.net
Thu Dec 1 16:14:53 EST 2011


Hi Liam:

On Thu, Dec 01, 2011 at 03:53:46PM -0500, Whalen, Liam wrote:
> Is there a SQL function or some other way to pass a bib id to a command
> and have it reorder the MARC XML so that MARC tags appear in sequential
> order within the MARC XML?
> 
> I'm using Evergreen 2.1.1, PostgreSQL 9.0.4, OpenSRF 2.0.1, and Ubuntu
> 10.04.
> 
> What I'm interested in doing is adding some 035 tags to some of our MARC
> records via SQL, but determining where to place the 035 in the MARC XML
> with SQL is not easy.  So, I was hoping I could just append a
> <datafield> tag at the end of the last <datafield> tag and then have a
> PostgreSQL function re-order the MARC XML for me.  Is that possible?

Yep, you could write a pl/perlu function that invokes MARC::File::XML and
iterates over each field of the incoming MARC record to create a new
MARC record using insert_fields_ordered(); that would give you a
MARC record with strictly numerically ordered fields.

See maintain_control_numbers() for an example of a MARC::File::XML
pl/perlu function currently in use.

Something is jumping up and down in the back of my mind telling me that
there are reasons you don't want to strictly order all fields - but it's
not present at hand.


More information about the Open-ils-dev mailing list