Closed nichtich closed 10 years ago
I added some fixes to Catmand::XML so transformation with XML::Struct could also be done in a fix. Instead of the proposed change, the DOM object should be passed for better performance. Serializing back XML should be avoided if possible.
Catmandu::Fix::Bind-s can be used to send DOM objects to xml fixes. i'll see if i can provide an example. You might want to write something like:
do
xml_parser(field)
xml_transform(...)
end
Where xml_parser is a Bind that can pass DOM to all fixes in a do-end block
If Camandu::OAI passed the parsed DOM fragment unserialized it can already be processed with fixes from Catmandu::XML:
xml_transform(_metadata, file: 'script.xsl')
xml_read(_metadata, simple: 1)
...
xml_write(_metadata)
On 21. Juni 2014 06:53:13 MESZ, Patrick Hochstenbach notifications@github.com wrote:
Catmandu::Fix::Bind-s can be used to send DOM objects to xml fixes. i'll see if i can provide an example. You might want to write something like:
do xml_parser(field) xml_transform(...) end
Where xml_parser is a Bind that can pass DOM to all fixes in a do-end block
Reply to this email directly or view it on GitHub: https://github.com/LibreCat/Catmandu-OAI/pull/3#issuecomment-46744690
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
Ok requires XML::Struct 0.19 to get this working. Will create a push a new version to CPAN
Support of multiple handlers as implemented in 0.06 is better. I only doubt that the namespace Catmandu::Importer::OAI::Parser::
is the right place because these handlers can be used for other formats (e.g. SRU and unAPI) too. How about Catmandu::Parser::DOM::
for handlers that convert DOM objects into Perl hashes? Having yet another package for each XML-based format (dc, marcxml, ...) seems not a good choice of design.
I further need a 'none' handler/parser that just keeps the DOM without parsing (the raw handler serializes the DOM), so it can be processed with fixes. Maybe this is a better default? I'll experiment further with Catmandu::XML :-)
Sure! If we can refactor this out of Catmandu::SRU and Catmandu::OAI I will gladly help.
I'm a bit worried about moving DOM-s around in Catmandu because non of our fixes, exporter have any contract that they should cope with blessed objects. I think Binds can be of help here to create blocks of code and specialised fixes that do like DOM. These Binds are by design created to cope with non-JSON input. E.g. you can work on binary objects with current fixes if you can create a correct Bind.
I will try to create an example..first need to fight with my OSX to get XML::LibXSLT installed
I removed the undocumented
_metadata
field that bloated the record and added a default handler for other metadata formats but "oai_dc", reusing the_metadata
field. Handlers can also be simple code references, so it is easier to override the new default handler, for instance with XSLT.