eulxml.xmlmap.mods
- Metadata Object Description Schema (MODS)¶
General Information¶
The Metadata Object Description Standard, or MODS is a schema developed and maintained by the Library of Congress for bibliographic records.
This module defines classes to handle common use cases for MODS metadata,
rooted in the MODSv34
object. It is not a complete mapping, though
it will likely grow closer to one as development progresses according to
user needs.
Root Classes: MODS and Friends¶
-
class
eulxml.xmlmap.mods.
MODS
(node=None, context=None, **kwargs)¶ Top-level
XmlObject
for a MODS metadata record. Inherits all standard top-level MODS fields fromBaseMods
and adds a mapping forRelatedItem
.-
ROOT_NAME
= u'mods'¶
-
ROOT_NAMESPACES
= {u'mods': u'http://www.loc.gov/mods/v3'}¶
-
ROOT_NS
= u'http://www.loc.gov/mods/v3'¶
-
XSD_SCHEMA
= u'http://www.loc.gov/standards/mods/v3/mods-3-4.xsd'¶
-
abstract
= <eulxml.xmlmap.fields.NodeField>¶
-
access_conditions
= <eulxml.xmlmap.fields.NodeListField>¶
-
create_abstract
(xmlobject)¶
-
create_name
(xmlobject)¶
-
create_note
(xmlobject)¶
-
create_origin_info
(xmlobject)¶
-
create_physical_description
(xmlobject)¶
-
create_record_info
(xmlobject)¶
-
create_title_info
(xmlobject)¶
-
genres
= <eulxml.xmlmap.fields.NodeListField>¶
-
id
= <eulxml.xmlmap.fields.StringField>¶
-
identifiers
= <eulxml.xmlmap.fields.NodeListField>¶
-
is_empty
()¶ Returns True if the root node contains no child elements, no attributes, and no text. Returns False if any are present.
-
is_valid
()¶ Determine if the current document is valid as far as we can determine. If there is a schema associated, check for schema validity. Otherwise, return True.
Return type: boolean
-
languages
= <eulxml.xmlmap.fields.NodeListField>¶
-
location
= <eulxml.xmlmap.fields.StringField>¶
-
locations
= <eulxml.xmlmap.fields.NodeListField>¶
-
name
= <eulxml.xmlmap.fields.NodeField>¶
-
names
= <eulxml.xmlmap.fields.NodeListField>¶
-
node
= None¶
-
note
= <eulxml.xmlmap.fields.NodeField>¶
-
notes
= <eulxml.xmlmap.fields.NodeListField>¶
-
origin_info
= <eulxml.xmlmap.fields.NodeField>¶
-
parts
= <eulxml.xmlmap.fields.NodeListField>¶
-
physical_description
= <eulxml.xmlmap.fields.NodeField>¶
-
record_info
= <eulxml.xmlmap.fields.NodeField>¶
-
resource_type
= <eulxml.xmlmap.fields.StringField>¶
-
schema_valid
()¶ Determine if the current document is schema-valid according to the configured XSD Schema associated with this instance of
XmlObject
.Return type: boolean Raises: Exception if no XSD schema is defined for this XmlObject instance
-
schema_validate
= True¶
-
schema_validation_errors
()¶ Retrieve any validation errors that occured during schema validation done via
is_valid()
.Returns: a list of lxml.etree._LogEntry
instancesRaises: Exception if no XSD schema is defined for this XmlObject instance
-
serialize
(stream=None, pretty=False)¶ Serialize the contents of the XmlObject to a stream. Serializes current node only; for the entire XML document, use
serializeDocument()
.If no stream is specified, returns a string. :param stream: stream or other file-like object to write content to (optional) :param pretty: pretty-print the XML output; boolean, defaults to False :rtype: stream passed in or an instance of
cStringIO.StringIO
-
serializeDocument
(stream=None, pretty=False)¶ Serialize the contents of the entire XML document (including Doctype declaration, if there is one), with an XML declaration, for the current XmlObject to a stream.
If no stream is specified, returns a string. :param stream: stream or other file-like object to write content to (optional) :param pretty: pretty-print the XML output; boolean, defaults to False :rtype: stream passed in or an instance of
cStringIO.StringIO
-
subjects
= <eulxml.xmlmap.fields.NodeListField>¶
-
title
= <eulxml.xmlmap.fields.StringField>¶
-
title_info
= <eulxml.xmlmap.fields.NodeField>¶
-
title_info_list
= <eulxml.xmlmap.fields.NodeListField>¶
-
validation_errors
()¶ Return a list of validation errors. Returns an empty list if the xml is schema valid or no schema is defined. If a schema is defined but
schema_validate
is False, schema validation will be skipped.Currently only supports schema validation.
Return type: list
-
xmlschema
¶ A parsed XSD schema instance of
lxml.etree.XMLSchema
; will be loaded the first time it is requested on any instance of this class if XSD_SCHEMA is set and xmlchema is None. If you wish to load and parse the schema at class definition time, instead of at class instance initialization time, you may want to define your schema in your subclass like this:XSD_SCHEMA = "http://www.openarchives.org/OAI/2.0/oai_dc.xsd" xmlschema = xmlmap.loadSchema(XSD_SCHEMA)
-
xsl_transform
(filename=None, xsl=None, return_type=None, **params)¶ Run an xslt transform on the contents of the XmlObject.
XSLT can be passed in as an XSLT object generated by
load_xslt()
or as filename or string. If a params dictionary is specified, its items will be passed as parameters to the XSL transformation, and any string values will automatically be encoded as XSL string parameters.Note
If XSL is being used multiple times, it is recommended to use :meth`:load_xslt` to load and compile the XSLT once.
Parameters: - filename – xslt filename (optional, one of file and xsl is required)
- xsl – xslt as string OR compiled XSLT object as returned by
load_xslt()
(optional) - return_type – type of object to return; optional, defaults to
XmlObject
; specify unicode or string for text output
Returns: an instance of
XmlObject
or the return_type specified
-
-
class
eulxml.xmlmap.mods.
MODSv34
(node=None, context=None, **kwargs)¶ XmlObject
for MODS version 3.4. Currently consists of all the same fields asMODS
, but loads the MODS version 3.4 schema for validation.-
ROOT_NAME
= u'mods'¶
-
ROOT_NAMESPACES
= {u'mods': u'http://www.loc.gov/mods/v3'}¶
-
ROOT_NS
= u'http://www.loc.gov/mods/v3'¶
-
XSD_SCHEMA
= u'http://www.loc.gov/standards/mods/v3/mods-3-4.xsd'¶
-
abstract
= <eulxml.xmlmap.fields.NodeField>¶
-
access_conditions
= <eulxml.xmlmap.fields.NodeListField>¶
-
create_abstract
(xmlobject)¶
-
create_name
(xmlobject)¶
-
create_note
(xmlobject)¶
-
create_origin_info
(xmlobject)¶
-
create_physical_description
(xmlobject)¶
-
create_record_info
(xmlobject)¶
-
create_title_info
(xmlobject)¶
-
genres
= <eulxml.xmlmap.fields.NodeListField>¶
-
id
= <eulxml.xmlmap.fields.StringField>¶
-
identifiers
= <eulxml.xmlmap.fields.NodeListField>¶
-
is_empty
()¶ Returns True if the root node contains no child elements, no attributes, and no text. Returns False if any are present.
-
is_valid
()¶ Determine if the current document is valid as far as we can determine. If there is a schema associated, check for schema validity. Otherwise, return True.
Return type: boolean
-
languages
= <eulxml.xmlmap.fields.NodeListField>¶
-
location
= <eulxml.xmlmap.fields.StringField>¶
-
locations
= <eulxml.xmlmap.fields.NodeListField>¶
-
name
= <eulxml.xmlmap.fields.NodeField>¶
-
names
= <eulxml.xmlmap.fields.NodeListField>¶
-
node
= None¶
-
note
= <eulxml.xmlmap.fields.NodeField>¶
-
notes
= <eulxml.xmlmap.fields.NodeListField>¶
-
origin_info
= <eulxml.xmlmap.fields.NodeField>¶
-
parts
= <eulxml.xmlmap.fields.NodeListField>¶
-
physical_description
= <eulxml.xmlmap.fields.NodeField>¶
-
record_info
= <eulxml.xmlmap.fields.NodeField>¶
-
resource_type
= <eulxml.xmlmap.fields.StringField>¶
-
schema_valid
()¶ Determine if the current document is schema-valid according to the configured XSD Schema associated with this instance of
XmlObject
.Return type: boolean Raises: Exception if no XSD schema is defined for this XmlObject instance
-
schema_validate
= True¶
-
schema_validation_errors
()¶ Retrieve any validation errors that occured during schema validation done via
is_valid()
.Returns: a list of lxml.etree._LogEntry
instancesRaises: Exception if no XSD schema is defined for this XmlObject instance
-
serialize
(stream=None, pretty=False)¶ Serialize the contents of the XmlObject to a stream. Serializes current node only; for the entire XML document, use
serializeDocument()
.If no stream is specified, returns a string. :param stream: stream or other file-like object to write content to (optional) :param pretty: pretty-print the XML output; boolean, defaults to False :rtype: stream passed in or an instance of
cStringIO.StringIO
-
serializeDocument
(stream=None, pretty=False)¶ Serialize the contents of the entire XML document (including Doctype declaration, if there is one), with an XML declaration, for the current XmlObject to a stream.
If no stream is specified, returns a string. :param stream: stream or other file-like object to write content to (optional) :param pretty: pretty-print the XML output; boolean, defaults to False :rtype: stream passed in or an instance of
cStringIO.StringIO
-
subjects
= <eulxml.xmlmap.fields.NodeListField>¶
-
title
= <eulxml.xmlmap.fields.StringField>¶
-
title_info
= <eulxml.xmlmap.fields.NodeField>¶
-
title_info_list
= <eulxml.xmlmap.fields.NodeListField>¶
-
validation_errors
()¶ Return a list of validation errors. Returns an empty list if the xml is schema valid or no schema is defined. If a schema is defined but
schema_validate
is False, schema validation will be skipped.Currently only supports schema validation.
Return type: list
-
xmlschema
¶ A parsed XSD schema instance of
lxml.etree.XMLSchema
; will be loaded the first time it is requested on any instance of this class if XSD_SCHEMA is set and xmlchema is None. If you wish to load and parse the schema at class definition time, instead of at class instance initialization time, you may want to define your schema in your subclass like this:XSD_SCHEMA = "http://www.openarchives.org/OAI/2.0/oai_dc.xsd" xmlschema = xmlmap.loadSchema(XSD_SCHEMA)
-
xsl_transform
(filename=None, xsl=None, return_type=None, **params)¶ Run an xslt transform on the contents of the XmlObject.
XSLT can be passed in as an XSLT object generated by
load_xslt()
or as filename or string. If a params dictionary is specified, its items will be passed as parameters to the XSL transformation, and any string values will automatically be encoded as XSL string parameters.Note
If XSL is being used multiple times, it is recommended to use :meth`:load_xslt` to load and compile the XSLT once.
Parameters: - filename – xslt filename (optional, one of file and xsl is required)
- xsl – xslt as string OR compiled XSLT object as returned by
load_xslt()
(optional) - return_type – type of object to return; optional, defaults to
XmlObject
; specify unicode or string for text output
Returns: an instance of
XmlObject
or the return_type specified
-
Title Info¶
MODS titleInfo
-
class
eulxml.xmlmap.mods.
TitleInfo
(node=None, context=None, **kwargs)¶ -
ROOT_NAME
= u'titleInfo'¶
-
is_empty
()¶ Returns True if all titleInfo subfields are not set or empty; returns False if any of the fields are not empty.
-
label
= <eulxml.xmlmap.fields.StringField>¶
-
non_sort
= <eulxml.xmlmap.fields.StringField>¶
-
part_name
= <eulxml.xmlmap.fields.StringField>¶
-
part_number
= <eulxml.xmlmap.fields.StringField>¶
-
subtitle
= <eulxml.xmlmap.fields.StringField>¶
-
title
= <eulxml.xmlmap.fields.StringField>¶
-
type
= <eulxml.xmlmap.fields.StringField>¶
-
Name¶
MODS name
-
class
eulxml.xmlmap.mods.
Name
(node=None, context=None, **kwargs)¶ XmlObject
for MODS name-
ROOT_NAME
= u'name'¶
-
affiliation
= <eulxml.xmlmap.fields.StringField>¶
-
display_form
= <eulxml.xmlmap.fields.StringField>¶
-
id
= <eulxml.xmlmap.fields.StringField>¶
-
name_parts
= <eulxml.xmlmap.fields.NodeListField>¶
-
roles
= <eulxml.xmlmap.fields.NodeListField>¶
-
type
= <eulxml.xmlmap.fields.StringField>¶
-
Origin Info¶
MODS originInfo
-
class
eulxml.xmlmap.mods.
OriginInfo
(node=None, context=None, **kwargs)¶ XmlObject
for MODS originInfo element (incomplete)-
ROOT_NAME
= u'originInfo'¶
-
captured
= <eulxml.xmlmap.fields.NodeListField>¶
-
copyright
= <eulxml.xmlmap.fields.NodeListField>¶
-
created
= <eulxml.xmlmap.fields.NodeListField>¶
-
is_empty
()¶ Returns True if all child date elements present are empty and other nodes are not set. Returns False if any child date elements are not empty or other nodes are set.
-
issued
= <eulxml.xmlmap.fields.NodeListField>¶
-
modified
= <eulxml.xmlmap.fields.NodeListField>¶
-
other
= <eulxml.xmlmap.fields.NodeListField>¶
-
publisher
= <eulxml.xmlmap.fields.StringField>¶
-
valid
= <eulxml.xmlmap.fields.NodeListField>¶
-
Language¶
MODS language
Physical Description¶
MODS physicalDescription
Note¶
MODS note
Subject¶
MODS subject
-
class
eulxml.xmlmap.mods.
Subject
(node=None, context=None, **kwargs)¶ -
ROOT_NAME
= u'subject'¶
-
create_name
(xmlobject)¶
-
geographic
= <eulxml.xmlmap.fields.StringField>¶
-
id
= <eulxml.xmlmap.fields.StringField>¶
-
name
= <eulxml.xmlmap.fields.NodeField>¶
-
title
= <eulxml.xmlmap.fields.StringField>¶
-
topic
= <eulxml.xmlmap.fields.StringField>¶
-
Identifer¶
MODS identifier
Access Condition¶
MODS accessCondition
Part¶
MODS part
-
class
eulxml.xmlmap.mods.
Part
(node=None, context=None, **kwargs)¶ -
ROOT_NAME
= u'part'¶
-
create_extent
(xmlobject)¶
-
details
= <eulxml.xmlmap.fields.NodeListField>¶
-
extent
= <eulxml.xmlmap.fields.NodeField>¶
-
is_empty
()¶ Returns True if details, extent, and type are not set or return True for
is_empty
; returns False if any of the fields are not empty.
-
type
= <eulxml.xmlmap.fields.StringField>¶
-
-
class
eulxml.xmlmap.mods.
PartDetail
(node=None, context=None, **kwargs)¶ -
ROOT_NAME
= u'detail'¶
-
is_empty
()¶ Returns False if no number value is set; returns True if any number value is set. Type attribute is ignored for determining whether or not this node should be considered empty.
-
number
= <eulxml.xmlmap.fields.StringField>¶
-
type
= <eulxml.xmlmap.fields.StringField>¶
-
-
class
eulxml.xmlmap.mods.
PartExtent
(node=None, context=None, **kwargs)¶ -
ROOT_NAME
= u'extent'¶
-
end
= <eulxml.xmlmap.fields.StringField>¶
-
is_empty
()¶ Returns False if no extent value is set; returns True if any extent value is set. Unit attribute is ignored for determining whether or not this node should be considered empty.
-
start
= <eulxml.xmlmap.fields.StringField>¶
-
total
= <eulxml.xmlmap.fields.StringField>¶
-
unit
= <eulxml.xmlmap.fields.StringField>¶
-
Record Info¶
MODS recordInfo
-
class
eulxml.xmlmap.mods.
RecordInfo
(node=None, context=None, **kwargs)¶ -
ROOT_NAME
= u'recordInfo'¶
-
change_date
= <eulxml.xmlmap.fields.StringField>¶
-
creation_date
= <eulxml.xmlmap.fields.StringField>¶
-
record_id
= <eulxml.xmlmap.fields.StringField>¶
-
record_origin
= <eulxml.xmlmap.fields.StringField>¶
-