Socket
Book a DemoInstallSign in
Socket

MergeAsXML

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

MergeAsXML

0.0.4
bundlerRubygems
Version published
Maintainers
1
Created
Source

MergeAsXML

This is a simple Ruby based command line tool that takes a delimited data file (like a CSV file) and merges it into a already existing XML file.

  MergeAsXML v1.0.0
      -i, --input filename             File containing input data
      -s separator                     The delimiter of each field in the input file (default: tab \t)
      -X file                          The XML file to merge the data into
      -p parent path                   The path of the parent node to insert at
      -b previous sibling path         The path of the sibling node to insert after
      -c next sibling path             The path of the sibling node to insert before
      -t template                      ERB template to populate (defaults to inbuilt default template)
      -d                               Dump default template to default.xml.erb
      -h                               Display this screen

The basic use case involves you having :

  • A delimited datafile, like a CSV file
  • An XML file

And you need to get the data from the datafile formatting and inserted into the right place in the XML file.

To do this you specify:

  • The datafile to use
  • The delimiter for the file. Default is tab.
  • An ERB template to control how the data is turned into XML.
  • The XML file to insert the output into.
  • An xpath expression to indicate where to insert the new XML. Only the first match is used.
  • Whether the xpath expression indicates the parent node for the new data (-p), or a sibling node to insert before (-c)or after (-b).

Here's an example of the command-line inserting CSV data as Markers into a Final Cut Pro XML export.

  MergeAsXML -i timecode-data.csv -s , -X FC_XML_EXPORT.XML -b /xmeml/sequence/ismasterclip -t markers.xml.erb

A backup copy of the XML file is made with the suffix .backup.

Installing

It's available as a Ruby Gem.

  sudo gem install MergeAsXML

Making templates

MergeAsXML uses ERB templates. You can read about ERB here.

You can get a copy of the default template using the -d parameter. It saves a copy of the default template in your current directory.

  MergeAsXML -d

The default template looks like this:

  <!-- generated data begins -->
  <% data.each_index do | index | %>
  <marker>
     <name>Marker #<%= index %></name>
     <comment><%= data[index][1] %></comment>
     <color>
        <alpha>0</alpha>
        <red>255</red>
        <green>0</green>
        <blue>0</blue>
     </color>
     <in><%= data[index][0] %></in>
     <out>-1</out>
  </marker>
  <% end %>
  <!-- generated data ends -->

The data from the input file goes into a simple 2D array called data. So each specific item can be accessed as such:

  data[row][col]

And you can step through each item using the .each_index operation.

FAQs

Package last updated on 26 May 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.