The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

FileMetadata::Store::XML

DESCRIPTION

This modules implements a store for the FileMetadata framework using a XML file for storage. This module does not implement any methods for accessing the information from the store.

It is important to note that information is written to the XML file only when the finish() method is called.

METHODS

new

See FileMetadata::Store

The new method creates and returns a reference to a new object.

The format for the config hash is as follows

  {
    
    file => '/tmp/f00jkdw.xml',

    root_element => 'meta-info',

    item_element => 'item',

    store => [{name => 'id',

               property => 'ID',

               type => 'attribute'},

              {name => 'timestamp',

               property => 'TIMESTAMP',

               type => 'element'},

              {name => 'author',

               property => 'FileMetadata::Miner::HTML::author',

               default => 'Jules Verne'}

             ]

  }

'file' is the path to which the information must be written. If the file already exists, it is assumed to have been written with the same configuration. The contents of the file are not checked for consistency with the given configuration.

'root_element' refers to the root element of the XML file. 'item_element' is used as to enclose meta information for each item. These items are optional and both would default to 'meta-info'. 'name' refers to the element or attribute name with which the corresponding 'property' will be stored. 'type' identifies whether the item should be written as a element or an attribute. It is possible to generate illegal XML by using a invalid value for 'name'. The 'default' value is used if the 'property' is not found in the meta hash as a key. 'type' and 'default' are optional. If 'type' is not specified, it defaults to 'element'. If 'default' is not specified, the property is ignored if not found.

The 'store' array is optional. If it is not present, each key in the meta hash is used as an element name with the '::' replaced by '_'. If the 'store' array is provided, it must contain information for the 'ID' and 'TIMESTAMP' properties.

The resulting XML output from this store would look as below.

  <meta-info>

    <item id="/abcd.def">

      <timestamp>1020200222</timestamp>

      <author>Scott Lee</author>

    </item>

    <item id="/wxyz.def">

      <timestamp>1320290459</timestamp>

      <author>Timothy Walker</author>

    </item>

  </meta-info>

store

See "store" in FileMetadata::Store

The store inserts required information from the meta hash into an internal hash.

remove

See "remove" in FileMetadata::Store

clear

See "clear" in FileMetadata::Store

has

See "has" in FileMetadata::Store

list

See "has" in FileMetadata::Store

finish

This method writes meta data held internally to the output file all at once.

VERSION

0.1 - This is the first release

REQUIRES

XML::Simple

AUTHOR

Midh Mulpuri midh@enjine.com

LICENSE

This software can be used under the terms of any Open Source Initiative approved license. A list of these licenses are available at the OSI site - http://www.opensource.org/licenses/