The DublinCore class¶
gamslib.objectcsv.dublincore.DublinCore
¶
Represents data from DC.xml.
Provides methods to access DC data with language support, and to validate the minimal GAMS requirements for the DX.XML file.
Initialize and parse the DC.xml file.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Path to the DC.xml file.
TYPE:
|
lookup_order
|
Preferred language order for fallback.
TYPE:
|
remove_linebreaks
classmethod
¶
get_en_element
¶
Return the value(s) of a Dublin Core element in English. If no English value is found, return the default value.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The name of the element without namespace (e.g. "title").
TYPE:
|
default
|
Default value if element is missing.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
list[str]: The value(s) of the element as a list of strings. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the element name is not a valid Dublin Core element. |
get_en_element_as_str
¶
Return all entries of a Dublin Core element in English as string.
Entries are separated by '; '.
Delimi
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The name of the element without namespace (e.g. "title").
TYPE:
|
default
|
Default value if element is missing.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The joined value(s) of the element as a string. Multiple values
TYPE:
|
str
|
are separated by ';'. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the element name is not a valid Dublin Core element. |
get_element
¶
Return the value(s) of a Dublin Core element as a list of strings.
If no entry in the preferred language is available, the function will search for entries in another language, depending on the lookup_order set during object creation. If no entry is found with a specified language, the function checks for an entry with no 'xml:lang' attribute. If still no value is found, the default value will be returned (as a list).
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The name of the element without namespace (e.g. "title").
TYPE:
|
preferred_lang
|
The preferred language of the element (e.g. "de").
TYPE:
|
default
|
The default value to return if no value is found.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
list[str]: The value(s) of the element as a list of strings. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the element name is not a valid Dublin Core element. |
get_element_as_str
¶
Return the value(s) of a Dublin Core element as a string.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The name of the element without namespace.
TYPE:
|
preferred_lang
|
The preferred language of the element.
TYPE:
|
default
|
The default value to return if no value is found.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The value(s) as a single string. For 'rights', formats as "name (url)"
TYPE:
|
str
|
if two values are present; otherwise, values are joined with ';'. |
get_element_all_langs
¶
Return all values of a Dublin Core element for all languages.
This includes unspecified languages.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The name of the element without namespace (e.g. "title").
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
list[str]: A list of all values for the element in all available |
list[str]
|
languages (including unspecified). |
list[str]
|
If the element is not found, an empty list is returned. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the element name is not a valid Dublin Core element. |
validate
¶
Validate the Dublin Core file.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the Dublin Core file is invalid. |