Provided by: libcatmandu-xsd-perl_0.04-1_all bug

NAME

       Catmandu::Fix::xpath_map - map values from a XML::LibXML::Element value to a field

SYNOPSIS

          #   <mets:dmdSec ID="dmd1">
          #    <mets:mdWrap MDTYPE="MODS">
          #     <mets:xmlData>
          #      <mods:mods xmlns:mods="http://www.loc.gov/mods/v3" ID="mods1" version="3.4">
          #        <mods:titleInfo>
          #         <mods:title>Alabama blues</mods:title>
          #        </mods:titleInfo>
          #      </mods:mods>
          #     </mets:xmlData>
          #    </mets:mdWrap>
          #   </mets:dmdSec>

          # The dmdSec.0.mdWrap.xmlData contains a XML::LibXML::Element
          # Map the value of the 'mods:titleInfo/mods:title' XPath to
          # a new field 'my_new_field'.
          # Optionally provide one or more namespace mappings to use
          xpath_map(
              dmdSec.0.mdWrap.xmlData,
              'mods:titleInfo/mods:title',
              my_new_field,
              -mods:'http://www.loc.gov/mods/v3'
          )

          # Result:
          #
          # 'my_new_field' => 'Alabama blues'

DESCRIPTION

       Not all XML fields in an XML Schema can be mapped to a Perl Hash using Catmandu::XSD.
       Especially <any> fields in a schema, which can contain any type of XML are problematic.
       These fields are mapped into a blessed XML::LibXML::Element object. Using the "xpath_map"
       Fix, on can access these blessed objects and extract data from it using XPaths.

METHOD

   xpath_map(xml_field, xpath, new_field [, namespace-prefix:namespace-url [,...]])
       Map an XML field at "xml_field" to "new_field" using an XPath expresssion "xpath".

SEE ALSO

       Catmandu::Fix