Source code for gavo.registry.model

"""
The schema and XML namespaces for OAI/VOR documents.
"""

#c Copyright 2008-2023, the GAVO project <gavo@ari.uni-heidelberg.de>
#c
#c This program is free software, covered by the GNU GPL.  See the
#c COPYING file in the source distribution.


from gavo import base
from gavo.utils.stanxml import Element, schemaURL, registerPrefix, xsiPrefix


[docs]class Error(base.Error): pass
# See stanxml for the root of all the following evil. # If you change schemaURL here, you will quite certainly have # to fix testtricks.VO_SCHEMATA as well. registerPrefix("oai", "http://www.openarchives.org/OAI/2.0/", schemaURL("OAI-PMH.xsd")) registerPrefix("oai_dc", "http://www.openarchives.org/OAI/2.0/oai_dc/", schemaURL("oai_dc.xsd")) registerPrefix("ri", "http://www.ivoa.net/xml/RegistryInterface/v1.0", schemaURL("RegistryInterface.xsd")) registerPrefix("vg", "http://www.ivoa.net/xml/VORegistry/v1.0", schemaURL("VORegistry.xsd")) registerPrefix("vr", "http://www.ivoa.net/xml/VOResource/v1.0", schemaURL("VOResource.xsd")) registerPrefix("dc", "http://purl.org/dc/elements/1.1/", schemaURL("simpledc20021212.xsd")) registerPrefix("vs", "http://www.ivoa.net/xml/VODataService/v1.1", schemaURL("VODataService.xsd")) registerPrefix("cs", "http://www.ivoa.net/xml/ConeSearch/v1.0", schemaURL("ConeSearch.xsd")) registerPrefix("sia", "http://www.ivoa.net/xml/SIA/v1.1", schemaURL("SIA.xsd")) registerPrefix("slap", "http://www.ivoa.net/xml/SLAP/v1.0", schemaURL("SLAP.xsd")) registerPrefix("ssap", "http://www.ivoa.net/xml/SSA/v1.1", schemaURL("SSA.xsd")) registerPrefix("tr", "http://www.ivoa.net/xml/TAPRegExt/v1.0", schemaURL("TAPRegExt.xsd")) registerPrefix("vstd", "http://www.ivoa.net/xml/StandardsRegExt/v1.0", schemaURL("StandardsRegExt.xsd")) registerPrefix("doc", "http://www.ivoa.net/xml/DocRegExt/v1", schemaURL("DocRegExt.xsd")) registerPrefix("voe", "http://www.ivoa.net/xml/VOEventRegExt/v2", schemaURL("VOEventRegExt.xsd")) registerPrefix("g-colstat", "http://dc.g-vo.org/ColStats-1", schemaURL("Colstats.xsd")) registerPrefix("eudc", "http://schema.eudat.eu/schema/kernel-1", schemaURL("eudat-core.xsd")) registerPrefix("dachs", "http://docs.g-vo.org/schemata/DaCHS.xsd", schemaURL("DaCHS.xsd")) class _ResourceNameMixin(object): _a_ivoId = None _name_a_ivoId = "ivo-id"
[docs]class OAI(object): """is a container for classes modelling OAI elements. """
[docs] class OAIElement(Element): _prefix = "oai"
[docs] class PMH(OAIElement): name_ = "OAI-PMH"
[docs] class responseDate(OAIElement): pass
[docs] class request(OAIElement): _mayBeEmpty = True _a_verb = None _a_metadataPrefix = None
[docs] class metadata(OAIElement): pass
[docs] class Identify(OAIElement): pass
[docs] class ListIdentifiers(OAIElement): pass
[docs] class ListRecords(OAIElement): pass
[docs] class GetRecord(OAIElement): pass
[docs] class ListMetadataFormats(OAIElement): pass
[docs] class ListSets(OAIElement): _mayBeEmpty = True
[docs] class header(OAIElement): _a_status = None
[docs] class error(OAIElement): _mayBeEmpty = True _a_code = None
[docs] class record(OAIElement): pass
[docs] class identifier(OAIElement): pass
[docs] class datestamp(OAIElement): pass
[docs] class setSpec(OAIElement): pass
[docs] class repositoryName(OAIElement): pass
[docs] class baseURL(OAIElement): pass
[docs] class adminEmail(OAIElement): pass
[docs] class earliestDatestamp(OAIElement): pass
[docs] class deletedRecord(OAIElement): pass
[docs] class granularity(OAIElement): pass
[docs] class description(OAIElement): pass
[docs] class protocolVersion(OAIElement): pass
[docs] class metadataFormat(OAIElement): pass
[docs] class metadataPrefix(OAIElement): pass
[docs] class schema(OAIElement): pass
[docs] class metadataNamespace(OAIElement): pass
[docs] class set(OAIElement): pass
[docs] class setName(OAIElement): pass
[docs] class setDescription(OAIElement): pass
[docs] class resumptionToken(OAIElement): pass
# optional attributes not supported here # The string value in here has a structure; see oaiinter.
[docs]class OAIDC: """is a container for OAI's Dublin Core metadata model. """
[docs] class OAIDCElement(Element): _prefix = "oai_dc"
[docs] class dc(OAIDCElement): pass
[docs]class VOR: """is a container for classes modelling elements from VO Resource. """
[docs] class VORElement(Element): _prefix = "vr" _local = True
[docs] class Resource(VORElement): # This is "abstract" in that only derived elements may be present # in an instance document (since VOR doesn't define any global elements). # Typically, this will be vr:Resource elements with some funky xsi:type _a_created = None _a_updated = None _a_status = None name_ = "Resource" _local = False _additionalPrefixes = frozenset(["vr", "ri", "xsi"]) def __repr__(self): # see if we can find out our identifier -- that's going to help # in debugging. identifier = "(unknown)" for child in self.iterChildrenWithName("identifier"): identifier = child.text_ break return "<%s: %s>"%( self.__class__.__name__.split(".")[-1], identifier)
[docs] class Organisation(Resource): _a_xsi_type = "vr:Organisation"
[docs] class Service(Resource): _a_xsi_type = "vr:Service"
[docs] class validationLevel(VORElement): _a_validatedBy = None
[docs] class title(VORElement): pass
[docs] class shortName(VORElement): pass
[docs] class ResourceName(VORElement): _a_ivoId = None _name_a_ivoId = "ivo-id" _a_altIdentifier = None
[docs] class identifier(VORElement): pass
[docs] class altIdentifier(VORElement): pass
[docs] class curation(VORElement): pass
[docs] class content(VORElement): pass
[docs] class creator(VORElement): pass
[docs] class contributor(ResourceName): pass
[docs] class date(VORElement): _a_role = None
[docs] class version(VORElement): pass
[docs] class contact(VORElement): pass
[docs] class publisher(ResourceName): pass
[docs] class facility(VORElement): pass
[docs] class instrument(ResourceName): pass
[docs] class name(VORElement): pass
[docs] class address(VORElement): pass
[docs] class email(VORElement): pass
[docs] class telephone(VORElement): pass
[docs] class subject(VORElement): pass
[docs] class description(VORElement): pass
[docs] class source(VORElement): _a_format = None
[docs] class referenceURL(VORElement): pass
[docs] class type(VORElement): pass
[docs] class contentLevel(VORElement): pass
[docs] class relationship(VORElement): def _setupNode(self): self.__isEmpty = None self._setupNodeNext(VOR.relationship)
[docs] def isEmpty(self): # special rule: a relationship is empty if there's no relatedResource # in them (this is a simplification of "don't count relationshipType # since it's always non-empty"). if self._isEmptyCache is None: self._isEmptyCache = True for c in self.iterChildrenOfType(VOR.relatedResource): self._isEmptyCache = False break return self._isEmptyCache
[docs] class relationshipType(VORElement): pass
[docs] class relatedResource(VORElement): _a_ivoId = None _name_a_ivoId = "ivo-id"
[docs] class rights(VORElement): _a_rightsURI = None
[docs] class capability(VORElement): name_ = "capability" _additionalPrefixes = xsiPrefix _a_standardID = None
[docs] class interface(VORElement): name_ = "interface" _additionalPrefixes = xsiPrefix _a_version = None _a_role = None _a_qtype = None
[docs] class WebBrowser(interface): _a_xsi_type = "vr:WebBrowser"
[docs] class WebService(interface): _a_xsi_type = "vr:WebService"
[docs] class wsdlURL(VORElement): pass
[docs] class accessURL(VORElement): _a_use = None
[docs] class mirrorURL(VORElement): pass
[docs] class securityMethod(VORElement):
[docs] def isEmpty(self): return self.standardId is None
_a_standardId = None
[docs]class RI: """is a container for classes modelling elements from IVOA Registry Interface. """
[docs] class RIElement(Element): _prefix = "ri"
[docs] class VOResources(RIElement): pass
[docs] class Resource(VOR.Resource): _prefix = "ri"
[docs]class VOG: """is a container for classes modelling elements from VO Registry. """
[docs] class VOGElement(Element): _prefix = "vg" _local = True
[docs] class Resource(RI.Resource): _a_xsi_type = "vg:Registry" _additionalPrefixes = frozenset(["vg", "xsi"])
[docs] class Authority(RI.Resource): _a_xsi_type = "vg:Authority" _additionalPrefixes = frozenset(["vg", "xsi"])
[docs] class capability(VOR.capability): _a_standardID = "ivo://ivoa.net/std/Registry"
[docs] class Harvest(capability): _a_xsi_type = "vg:Harvest" _additionalPrefixes = frozenset(["vg", "xsi", "vs"])
[docs] class Search(VOGElement): _a_xsi_type = "vg:Search" _additionalPrefixes = frozenset(["vg", "xsi", "vs"])
[docs] class OAIHTTP(VOR.interface): _a_xsi_type = "vg:OAIHTTP"
# namespace declaration has happened in enclosing element
[docs] class OAISOAP(VOR.interface): _a_xsi_type = "vg:OAISOAP"
# namespace declaration has happened in enclosing element
[docs] class full(VOGElement): pass
[docs] class managedAuthority(VOGElement): pass
[docs] class validationLevel(VOGElement): pass
[docs] class description(VOGElement): pass
[docs] class interface(VOGElement): pass
[docs] class maxRecords(VOGElement): pass
[docs] class extensionSearchSupport(VOGElement): pass
[docs] class optionalProtocol(VOGElement): pass
[docs] class managingOrg(VOGElement, _ResourceNameMixin): pass
[docs]class DC: """is a container for classes modelling elements from Dublin Core. """
[docs] class DCElement(Element): _prefix = "dc"
[docs] class contributor(DCElement): pass
[docs] class coverage(DCElement): pass
[docs] class creator(DCElement): pass
[docs] class date(DCElement): pass
[docs] class description(DCElement): pass
[docs] class format(DCElement): pass
[docs] class identifier(DCElement): pass
[docs] class language(DCElement): pass
[docs] class publisher(DCElement): pass
[docs] class relation(DCElement): pass
[docs] class rights(DCElement): pass
[docs] class source(DCElement): pass
[docs] class subject(DCElement): pass
[docs] class title(DCElement): pass
[docs] class type(DCElement): pass
[docs]class VS: """A container for classes modelling elements from VODataService 1.2. """
[docs] class VSElement(Element): _prefix = "vs" _local = True
[docs] class DataCollection(RI.Resource): _a_xsi_type = "vs:DataCollection" _additionalPrefixes = frozenset(["vs", "xsi"])
[docs] class tableset(VSElement): _additionalPrefixes = xsiPrefix _childSequence = ["schema"]
[docs] class schema(VSElement): _childSequence = ["name", "title", "description", "utype", "table"]
[docs] class title(VSElement): pass
[docs] class utype(VSElement): pass
[docs] class nrows(VSElement): pass
[docs] class table(VSElement): _a_type = None _childSequence = ["name", "title", "description", "utype", "nrows", "column", "foreignKey"]
[docs] class foreignKey(VSElement): _childSequence = ["targetTable", "fkColumn", "description", "utype"]
[docs] class targetTable(VSElement): pass
[docs] class fkColumn(VSElement): _childSequence = ["fromColumn", "targetColumn"]
[docs] class fromColumn(VSElement): pass
[docs] class targetColumn(VSElement): pass
[docs] class flag(VSElement): pass
[docs] class regionOfRegard(VSElement): pass
[docs] class facility(VSElement): pass
[docs] class instrument(VSElement): pass
[docs] class coverage(VSElement): pass
[docs] class footprint(VSElement): _a_ivoId = None _name_a_ivoId = "ivo-id"
[docs] class waveband(VSElement): pass
[docs] class spectral(VSElement): pass
[docs] class spatial(VSElement): pass
[docs] class temporal(VSElement): pass
[docs] class format(VSElement): _a_isMIMEType = None
[docs] class accessURL(VSElement): pass
[docs] class ParamHTTP(VOR.interface): _a_xsi_type = "vs:ParamHTTP" _additionalPrefixes = frozenset(["vg", "xsi"])
[docs] class resultType(VSElement): pass
[docs] class queryType(VSElement): pass
[docs] class param(VSElement): _a_std = "false"
[docs] class name(VSElement): pass
[docs] class description(VSElement): pass
[docs] class unit(VSElement): pass
[docs] class ucd(VSElement): pass
[docs] class Service(VOR.Resource): pass
[docs] class DataResource(Service): _a_xsi_type = "vs:DataResource" _additionalPrefixes = frozenset(["vs", "xsi"])
[docs] class DataService(DataResource): _a_xsi_type = "vs:DataService"
[docs] class CatalogResource(DataResource): _a_xsi_type = "vs:CatalogResource"
[docs] class CatalogService(CatalogResource): _a_xsi_type = "vs:CatalogService" _additionalPrefixes = frozenset(["vs", "xsi"])
[docs] class ServiceReference(VSElement): _a_ivoId = None _name_a_ivoId = "ivo-id"
# column for now contains our prototype g-colstat attributes; # these ought to be removed as we leave the prototyping state. # In particular, the _additionalPrefixes should go again then
[docs] class column(VSElement): _additionalPrefixes = frozenset(["g-colstat"]) _a_minValue = None _name_a_minValue = "g-colstat:min-value" _a_maxValue = None _name_a_maxValue = "g-colstat:max-value" _a_median = None _name_a_median = "g-colstat:median" _a_percentile03 = None _name_a_percentile03 = "g-colstat:percentile03" _a_percentile97 = None _name_a_percentile97 = "g-colstat:percentile97" _a_fillFactor = None _name_a_fillFactor = "g-colstat:fillFactor"
class dataType(VSElement): name_ = "dataType" _additionalPrefixes = xsiPrefix _a_arraysize = None _a_delim = None _a_extendedSchema = None _a_extendedType = None _a_xsi_type = None
[docs] class dataType(dataType): name_ = "dataType"
[docs] class voTableDataType(dataType): name_ = "dataType" _a_xsi_type = "vs:VOTableType"
[docs] class tapType(dataType): name_ = "dataType" _a_size = None _a_xsi_type = "vs:TAPType"
[docs]class SIA(object): """A container for classes modelling elements for describing simple image access services. """
[docs] class SIAElement(Element): _prefix = "sia" _local = True
[docs] class interface(VOR.interface): _prefix = "sia" _a_role = "std" _additionalPrefixes = frozenset(["vs", "xsi"]) _a_xsi_type = "vs:ParamHTTP"
[docs] class capability(VOR.capability): _a_standardID = "ivo://ivoa.net/std/SIA" _a_xsi_type = "sia:SimpleImageAccess" _additionalPrefixes = frozenset(["sia", "xsi"])
[docs] class capability2(capability): # an artificial class to let me fix the standard id for SIAPv2 _a_standardID = "ivo://ivoa.net/std/SIA#query-2.0"
[docs] class imageServiceType(SIAElement): pass
[docs] class maxQueryRegionSize(SIAElement): pass
[docs] class maxImageExtent(SIAElement): pass
[docs] class maxImageSize(SIAElement): pass
[docs] class maxFileSize(SIAElement): pass
[docs] class maxRecords(SIAElement): pass
[docs] class long(SIAElement): pass
[docs] class lat(SIAElement): pass
[docs] class testQuery(SIAElement): pass
[docs] class pos(SIAElement): pass
[docs] class size(SIAElement): pass
[docs]class SCS(object): """A container for elements describing Simple Cone Search services. """
[docs] class SCSElement(Element): _prefix = "cs" _local = True
[docs] class interface(VOR.interface): _prefix = "cs" _a_role = "std" _a_xsi_type = "vs:ParamHTTP" _additionalPrefixes = frozenset(["xsi", "vs"])
[docs] class capability(VOR.capability): _a_standardID = "ivo://ivoa.net/std/ConeSearch" _a_xsi_type = "cs:ConeSearch" _additionalPrefixes = frozenset(["xsi", "vs"])
[docs] class maxSR(SCSElement): pass
[docs] class maxRecords(SCSElement): pass
[docs] class verbosity(SCSElement): pass
[docs] class testQuery(SCSElement): pass
[docs] class ra(SCSElement): pass
[docs] class dec(SCSElement): pass
[docs] class sr(SCSElement): pass
[docs] class extras(SCSElement): pass
[docs]class SSAP(object): """A container for the elements of the SSA registry extension. """
[docs] class SSAElement(Element): _prefix = "ssap" _local = True
[docs] class capability(VOR.capability): _a_standardID = "ivo://ivoa.net/std/SSA" _a_xsi_type = "ssap:SimpleSpectralAccess" _additionalPrefixes = frozenset(["xsi", "vs"])
[docs] class interface(VOR.interface): _prefix = "ssap" _a_role = "std" _additionalPrefixes = frozenset(["vs", "xsi"]) _a_xsi_type = "vs:ParamHTTP"
[docs] class complianceLevel(SSAElement): pass
[docs] class dataSource(SSAElement): pass
[docs] class creationType(SSAElement): pass
[docs] class maxSearchRadius(SSAElement): pass
[docs] class maxRecords(SSAElement): pass
[docs] class defaultMaxRecords(SSAElement): pass
[docs] class maxAperture(SSAElement): pass
[docs] class maxFileSize(SSAElement): pass
[docs] class supportedFrame(SSAElement): pass
[docs] class testQuery(SSAElement): pass
[docs] class queryDataCmd(SSAElement): pass
[docs]class SLAP(object): """A container for the elements of the SSA registry extension. """
[docs] class SLAPElement(Element): _prefix = "slap" _local = True
[docs] class capability(VOR.capability): _a_standardID = "ivo://ivoa.net/std/SLAP" _a_xsi_type = "slap:SimpleLineAccess" _additionalPrefixes = frozenset(["xsi", "vs"])
[docs] class interface(VOR.interface): _a_role = "std" _additionalPrefixes = frozenset(["vs", "xsi"]) _a_xsi_type = "vs:ParamHTTP"
[docs] class complianceLevel(SLAPElement): pass
[docs] class dataSource(SLAPElement): pass
[docs] class testQuery(SLAPElement): pass
[docs] class queryDataCmd(SLAPElement): pass
[docs]class TR(object): """A container for elements describing TAP services. """
[docs] class TRElement(Element): _prefix = "tr" _local = True
[docs] class interface(VOR.interface): _a_role = "std" _a_xsi_type = "vs:ParamHTTP" _additionalPrefixes = frozenset(["xsi", "vs"])
[docs] class daliInterface(VOR.interface): name_ = "interface" _a_role = "std" _a_xsi_type = "tr:DALIInterface" _additionalPrefixes = frozenset(["xsi"])
[docs] class capability(VOR.capability): _a_standardID = "ivo://ivoa.net/std/TAP" _a_xsi_type = "tr:TableAccess" _additionalPrefixes = frozenset(["tr", "xsi"])
[docs] class endpoint(TRElement): pass
[docs] class meta(TRElement): _a_about = None _a_property = None _a_resource = None
[docs] class dataModel(TRElement): _a_ivoId = None _name_a_ivoId = "ivo-id"
[docs] class label(TRElement): pass
[docs] class language(TRElement): _a_LANG = None
[docs] class outputFormat(TRElement): _a_FORMAT = None _a_mime = None _a_ivoId = None _name_a_ivoId = "ivo-id"
[docs] class uploadMethod(TRElement): _mayBeEmpty = True _a_protocol = None _a_ivoId = None _name_a_ivoId = "ivo-id"
[docs] class default(TRElement): _a_unit = None
[docs] class hard(TRElement): _a_unit = None
[docs] class version(TRElement): _a_ivoId = None _name_a_ivoId = "ivo-id"
[docs] class languageFeatures(TRElement): _a_type = None
[docs] class alias(TRElement): pass
[docs] class description(TRElement): pass
[docs] class executionDuration(TRElement): pass
[docs] class mime(TRElement): pass
[docs] class name(TRElement): pass
[docs] class parameter(TRElement): pass
[docs] class protocol(TRElement): pass
[docs] class retentionPeriod(TRElement): pass
[docs] class outputLimit(TRElement): pass
[docs] class form(TRElement): pass
[docs] class uploadLimit(TRElement): pass
[docs] class feature(TRElement): pass
[docs]class VSTD(object): """A container for elements from StandardsRegExt. """
[docs] class VSTDElement(Element): _prefix = "vstd" _local = True
[docs] class endorsedVersion(VSTDElement): _a_status = "n/a" _a_use = "preferred"
[docs] class Standard(RI.Resource): _a_xsi_type = "vstd:Standard" _additionalPrefixes = frozenset(["vstd", "xsi"])
[docs] class deprecated(VSTDElement): pass
[docs] class key(VSTDElement): pass
[docs] class description(VSTDElement): pass
[docs] class name(VSTDElement): pass
[docs]class DOC(object): """A container for elements from DocRegExt. """
[docs] class DOCElement(Element): _prefix = "doc" _local = True
[docs] class Document(RI.Resource): _a_xsi_type = "doc:Document" _additionalPrefixes = frozenset(["doc", "xsi"])
[docs] class capability(DOCElement): _a_xsi_type = "doc:Edition" _a_languageCode = None _a_locTitle = None
[docs] class languageCode(DOCElement): pass
[docs] class locTitle(DOCElement): pass
[docs]class DaFut(object): """A container for XSD elements we want to push into other schemas one of these days ("DaCHS Future"). """
[docs] class DaFutElement(Element): _prefix = "dachs" _local = True
[docs] class daliInterface(VOR.interface): name_ = "interface" _a_role = "std" _a_xsi_type = "dachs:DALIInterface" _additionalPrefixes = frozenset(["xsi"])
[docs] class endpoint(DaFutElement): pass
[docs] class meta(DaFutElement): _a_about = None _a_property = None _a_resource = None