The documentation for action_context and response_context shows a basic example of how to use them to create a new output format. Those basically replace steps 2 and 3 in the use case you linked to. Step 4 is pretty much the same – that’s where you create a view that actually constructs your XML.

I don’t know of a minimal model plugin aside from those off the top of my head.

Bad on us…the documentation was wrong. I pushed up a change, but not sure how long it will take to update on the readthedocs site.

The wrong things are:

define_action_context should be action_contexts (note the s)define_response_contexts should be response_contexts

The names of the functions change accordingly: filterResponseContexts and filterActionContexts

A plugin that does similar things is Geolocation. It sets up KML output for building the maps using the same system, so you’ll see the same filters defined, and the output in views/shared/browse.kml.php

Well, the error comes from ExportEacCpfPlugin::exportItem() not being defined. It looks like that’s where you would be generating the XML and echoing it back out. I often find it easier to just build the XML in the view itself, passing in whatever variables or data you need. That said, I don’t know the details of EacCpf, so there might be things I’m not aware of that make it make more sense to build it in the plugin function, but that’s usually the exception to the rule.

That’s right, now it works perfectly.
Is there a way I can define this output format is enable just for a particular collection or element type and not for all the items ?
Actually it would be useless and a bit strange to propose this output for example for bibliographical items.

Good question! Coincidentally, I’ve been digging into it lately for one of my projects.

I think the best way at it is to look at the controller key that’s passed in with the $args to the action_contexts filter. It will depend on the details of what you’re doing, but that should give you a path to the info you need.

This simplified example only adds a VRA output context to Items, but does not add it for item id 3780. For a real check, you’d probably dig up the actual item from the database and make whatever checks are needed.