예제 #1
0
def fbc_oai_dc_writer(element, metadata):
    """FBC notified us that original writer does not output all necessary namespace declarations.
    """
    e_dc = SubElement(element,
                      nsoaidc('dc'),
                      nsmap={
                          'oai_dc': NS_OAIDC,
                          'dc': NS_DC,
                          'xsi': NS_XSI
                      })
    e_dc.set('{%s}schemaLocation' % NS_XSI,
             '%s http://www.openarchives.org/OAI/2.0/oai_dc.xsd' % NS_OAIDC)
    map = metadata.getMap()
    for name in [
            'title',
            'creator',
            'subject',
            'description',
            'publisher',
            'contributor',
            'date',
            'type',
            'format',
            'identifier',
            'source',
            'language',
            'relation',
            'coverage',
            'rights',
    ]:
        for value in map.get(name, []):
            e = SubElement(e_dc, nsdc(name))
            e.text = value
예제 #2
0
def qdc_writer(element, metadata):
    """FBC notified us that original writer does not output all necessary namespace declarations.
    """
    nsmap = {
        'oai_dc': NS_OAIDC,
        'dc': NS_DC,
        'xsi': NS_XSI,
        'dcterms': NS_DCTERMS
    }
    map = metadata.getMap()
    for name in [
            'title',
            'creator',
            'subject',
            'description',
            'publisher',
            'contributor',
            'date',
            'type',
            'format',
            'identifier',
            'source',
            'language',
            'relation',
            'coverage',
            'rights',
    ]:
        for value in map.get(name, []):
            e = SubElement(element, nsdc(name), nsmap=nsmap)
            e.text = value

    for name in ['hasPart', 'isPartOf']:
        for value in map.get(name, []):
            e = SubElement(element, nsdcterms(name), nsmap=nsmap)
            e.text = value
예제 #3
0
def fbc_oai_dc_writer(element, metadata):
    """FBC notified us that original writer does not output all necessary namespace declarations.
    """
    e_dc = SubElement(element, nsoaidc('dc'),
                      nsmap={'oai_dc': NS_OAIDC, 'dc': NS_DC, 'xsi': NS_XSI})
    e_dc.set('{%s}schemaLocation' % NS_XSI,
             '%s http://www.openarchives.org/OAI/2.0/oai_dc.xsd' % NS_OAIDC)
    map = metadata.getMap()
    for name in [
        'title', 'creator', 'subject', 'description', 'publisher',
        'contributor', 'date', 'type', 'format', 'identifier',
        'source', 'language', 'relation', 'coverage', 'rights',
        ]:
        for value in map.get(name, []):
            e = SubElement(e_dc, nsdc(name))
            e.text = value
예제 #4
0
def rdf_writer(element, metadata):
    e_rdf = SubElement(element, nsrdf('RDF'),
                       nsmap={'rdf': NSRDF, 'ow': NSOW, 'xsi': NS_XSI,
                              'dc': NS_DC})
    e_rdf.set('{%s}schemaLocation' % NS_XSI,
              '%s http://www.openarchives.org/OAI/2.0/rdf.xsd' % RDF_SCHEMA)
    rdf_pub = SubElement(e_rdf, nsow('Publication'))
    map = metadata.getMap()
    for ident in map.get('identifier', []):
        if ident.startswith('http://'):
            rdf_pub.set('{%s}about' % NSRDF, '%s' % (ident))
    for name in ['title', 'creator', 'subject', 'description', 'publisher',
                 'contributor', 'date', 'type', 'format', 'identifier',
                 'source', 'language', 'relation', 'coverage', 'rights']:
        for value in map.get(name, []):
            e = SubElement(rdf_pub, nsdc(name))
            e.text = value
예제 #5
0
def qdc_writer(element, metadata):
    """FBC notified us that original writer does not output all necessary namespace declarations.
    """
    nsmap={'oai_dc': NS_OAIDC, 'dc': NS_DC, 'xsi': NS_XSI, 'dcterms': NS_DCTERMS}
    map = metadata.getMap()
    for name in [
        'title', 'creator', 'subject', 'description', 'publisher',
        'contributor', 'date', 'type', 'format', 'identifier',
        'source', 'language', 'relation', 'coverage', 'rights',
        ]:
        for value in map.get(name, []):
            e = SubElement(element, nsdc(name), nsmap=nsmap)
            e.text = value

    for name in ['hasPart', 'isPartOf']:
        for value in map.get(name, []):
            e = SubElement(element, nsdcterms(name), nsmap=nsmap)
            e.text = value
예제 #6
0
def lang_aware_oai_dc_writer(element, metadata):
    e_dc = SubElement(
        element,
        server.nsoaidc("dc"),
        nsmap={
            "oai_dc": server.NS_OAIDC,
            "dc": server.NS_DC,
            "xsi": server.NS_XSI
        },
    )
    e_dc.set(
        "{%s}schemaLocation" % server.NS_XSI,
        "%s http://www.openarchives.org/OAI/2.0/oai_dc.xsd" % server.NS_DC,
    )
    map = metadata.getMap()
    for name in [
            "title",
            "creator",
            "subject",
            "description",
            "publisher",
            "contributor",
            "date",
            "type",
            "format",
            "identifier",
            "source",
            "language",
            "relation",
            "coverage",
            "rights",
    ]:
        for value in map.get(name, []):
            e = SubElement(e_dc, server.nsdc(name))
            if isinstance(value, dict):
                e.text = value["text"]
                if "lang" in value:
                    e.set("{http://www.w3.org/XML/1998/namespace}lang",
                          value["lang"])
            else:
                e.text = value