def format_element(bfo, type='xml', encodeForXML='yes'): """ Prints the complete current record as XML. @param type: the type of xml. Can be 'xml', 'oai_dc', 'marcxml', 'xd' @param encodeForXML: if 'yes', replace all < > and & with html corresponding escaped characters. """ from invenio.bibformat_utils import record_get_xml from invenio.textutils import encode_for_xml #Can be used to output various xml flavours. out = record_get_xml(bfo.recID, format=type, on_the_fly=True) if encodeForXML.lower() == 'yes': return encode_for_xml(out) else: return out
def record_get_xml(recID, format='xm', decompress=zlib.decompress): """ Returns an XML string of the record given by recID. The function builds the XML directly from the database, without using the standard formatting process. 'format' allows to define the flavour of XML: - 'xm' for standard XML - 'marcxml' for MARC XML - 'oai_dc' for OAI Dublin Core - 'xd' for XML Dublin Core If record does not exist, returns empty string. @param recID: the id of the record to retrieve @return: the xml string of the record """ return bibformat_utils.record_get_xml(recID=recID, format=format, decompress=decompress)