####
my %book_columns = (
'Book_Id' => '@publisherId',
'Book_Platform' => '@platform',
'Book_Publisher' => '@publisher',
);
my %chapter_columns = (
'Chapter_Doi' => 'book:meta/@doi',
'Chapter_Doi_Prefix' => 'substring-before(book:meta/@doi,"/")',
'Chapter_Id' => '@id',
'Chapter_Title' => 'book:locator[contains(@xlink:href, "format=epub")]/@xlink:title',
);
##
##
my $dom = $parser->parse_string(book.xml);
my $root = $dom->documentElement();
my $xpc = XML::LibXML::XPathContext->new($root);
$xpc->registerNs('book', 'http://api.iop.org/Book/1.0/');
$xpc->registerNs('xlink', 'http://www.w3.org/1999/xlink');
foreach my $chapter_node ($xpc->findnodes('/book:bookResource/book:book/book:meta | /book:bookResource/book:book/book:contents/book:chapter'))
{
foreach my $col(qw/Chapter_Id Chapter_Title Book_Id Book_Publisher Book_Platform Chapter_Doi_Prefix Chapter_Doi Chapter_Id/)
{
print $xpc->findvalue($chapter_columns{$col}, $chapter_node);
}
}