-else {
-
-print $cgi->header( -type =>'application/xml' );
-
-print "<?xml version='1.0' encoding='utf-8' ?>
-<formats>
-<!-- <format name=\"opac\" type=\"text/html\"/> -->
-<!-- <format name=\"html\" type=\"text/html\"/> -->
-<!-- <format name=\"htmlholdings\" type=\"text/html\"/> -->
-<!-- <format name=\"html-full\" type=\"text/html\"/> -->
-<!-- <format name=\"htmlholdings-full\" type=\"text/html\"/> -->
-<!-- <format name=\"atom\" type=\"application/xml\" namespace_uri=\"http://www.w3.org/2005/Atom\" docs=\"http://www.ietf.org/rfc/rfc4287.txt\"/> -->
-<!-- <format name=\"atom-full\" type=\"application/xml\" namespace_uri=\"http://www.w3.org/2005/Atom\" docs=\"http://www.ietf.org/rfc/rfc4287.txt\"/> -->
-<format name=\"marcxml\" type=\"application/xml\" namespace_uri=\"http://www.loc.gov/MARC21/slim\" docs=\"http://www.loc.gov/marcxml/\" schema_location=\"http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\"/>
-<format name=\"marcxml-full\" type=\"application/xml\" namespace_uri=\"http://www.loc.gov/MARC21/slim\" docs=\"http://www.loc.gov/marcxml/\" schema_location=\"http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\"/>
-<format name=\"mods\" type=\"application/xml\" namespace_uri=\"http://www.loc.gov/mods/\" docs=\"http://www.loc.gov/mods/\" schema_location=\"http://www.loc.gov/standards/mods/mods.xsd\"/>
-<format name=\"mods-full\" type=\"application/xml\" namespace_uri=\"http://www.loc.gov/mods/\" docs=\"http://www.loc.gov/mods/\" schema_location=\"http://www.loc.gov/standards/mods/mods.xsd\"/>
-<format name=\"mods3\" type=\"application/xml\" namespace_uri=\"http://www.loc.gov/mods/v3\" docs=\"http://www.loc.gov/mods/\" schema_location=\"http://www.loc.gov/standards/mods/v3/mods-3-1.xsd\"/>
-<format name=\"mods3-full\" type=\"application/xml\" namespace_uri=\"http://www.loc.gov/mods/v3\" docs=\"http://www.loc.gov/mods/\" schema_location=\"http://www.loc.gov/standards/mods/v3/mods-3-1.xsd\"/>
-<format name=\"oai_dc\" type=\"application/xml\" namespace_uri=\"http://www.openarchives.org/OAI/2.0/oai_dc/\" schema_location=\"http://www.openarchives.org/OAI/2.0/oai_dc.xsd\"/>
-<format name=\"rdfdc\" type=\"application/xml\" namespace_uri=\"http://purl.org/dc/elements/1.1/\" schema_location=\"http://purl.org/dc/elements/1.1/\"/>
-<format name=\"rss2\" type=\"application/xml\"/>
-<format name=\"rss2-full\" type=\"application/xml\"/>
-<format name=\"srw_dc\" type=\"application/xml\" namespace_uri=\"info:srw/schema/1/dc-schema\" schema_location=\"http://www.loc.gov/z3950/agency/zing/srw/dc-schema.xsd\"/>
-</formats>
-";
+exit 0;
+
+sub emit_formats {
+ my $id = shift;
+
+ if (defined $id) {
+ print $cgi->header( -type =>'application/xml', -status => '300 multiple choices' );
+ } else {
+ print $cgi->header( -type =>'application/xml' );
+ }
+
+ print "<?xml version='1.0' encoding='utf-8' ?>\n";
+ if (defined $id) {
+ print qq(<formats id="$id">\n);
+ } else {
+ print "<formats>\n";
+ }
+
+ my $marcflavour = uc(C4::Context->preference('marcflavour'));
+ foreach my $format (sort keys %{ $format_to_stylesheet_map->{$marcflavour} }) {
+ print $format_info->{$format}, "\n";
+ }
+ print "</formats>\n";
+ return;