@classmethod def get_element_class(cls, name): """Returns the APP or Atom class used to represent name. Overrides :py:meth:`~pyslet.rfc4287.AtomDocument.get_element_class` when the namespace is :py:data:`APP_NAMESPACE`.""" if name[0] == APP_NAMESPACE: return cls.classMap.get( name, atom.AtomDocument.classMap.get((name[0], None), APPElement)) else: return atom.AtomDocument.get_element_class(name) xmlns.map_class_elements(Document.classMap, globals()) class Slug(object): """Represents an HTTP slug header value. slug The opaque slug as a unicode string The built-in str function can be used to format instances according to the grammar defined in the specification. Instances must be treated as immutable, they define comparison methods and a hash implementation to allow them to be used as keys in dictionaries."""
core.QTIElement.__init__(self, parent) self.outcomeIdentifier = None self.showHide = None self.identifier = None self.title = None def add_child(self, childClass, name=None): if issubclass(childClass, html.FlowMixin): return core.QTIElement.add_child(self, childClass, name) else: # This child cannot go in here raise core.QTIValidityError( "%s in %s" % (repr(name), self.__class__.__name__)) xmlns.map_class_elements(core.QTIDocument.classMap, globals()) xmlns.map_class_elements(core.QTIDocument.classMap, variables) xmlns.map_class_elements(core.QTIDocument.classMap, processing) xmlns.map_class_elements(core.QTIDocument.classMap, content) xmlns.map_class_elements(core.QTIDocument.classMap, interactions) xmlns.map_class_elements(core.QTIDocument.classMap, items) xmlns.map_class_elements(core.QTIDocument.classMap, tests) xmlns.map_class_elements(core.QTIDocument.classMap, expressions) xmlns.map_class_elements(core.QTIDocument.classMap, md) # also add in the profile of HTML but with the namespace rewritten to ours for name in QTI_HTMLProfile: eClass = html.XHTMLDocument.class_map.get( (html.XHTML_NAMESPACE, name), None) if eClass: core.QTIDocument.classMap[(core.IMSQTI_NAMESPACE, name)] = eClass else:
"""""" xmlns.XMLNSDocument.__init__(self, **args) self.defaultNS = IMSCC_CP_NAMESPACE self.make_prefix(xsi.XMLSCHEMA_NAMESPACE, 'xsi') self.make_prefix(IMSCC_LOMMANIFEST_NAMESPACE, 'lomimscc') self.make_prefix(IMSCC_LOMRESOURCE_NAMESPACE, 'lom') schemaLocation = [IMSCC_CP_NAMESPACE, IMSCC_CP_SCHEMALOCATION, IMSCC_LOMMANIFEST_NAMESPACE, IMSCC_LOMMANIFEST_SCHEMALOCATION, IMSCC_LOMRESOURCE_NAMESPACE, IMSCC_LOMRESOURCE_SCHEMALOCATION] if isinstance(self.root, imscp.CPElement): self.root.set_attribute( (xsi.XMLSCHEMA_NAMESPACE, 'schemaLocation'), string.join(schemaLocation, ' ')) def get_element_class(self, name): eClass = ManifestDocument.classMap.get( name, ManifestDocument.classMap.get((name[0], None), xmlns.XMLNSElement)) return eClass xmlns.map_class_elements(ManifestDocument.classMap, globals()) # xmlns.map_class_elements(ManifestDocument.classMap,imsmd) # xmlns.map_class_elements(ManifestDocument.classMap,imsqti) # Add other supported metadata schemas in here class ContentPackage(imscp.ContentPackage): ManifestDocumentClass = ManifestDocument class CommonCartridge(v1p0.CommonCartridge): ContentPackageClass = ContentPackage
self.make_prefix(IMSCC_LOMRESOURCE_NAMESPACE, 'lom') schemaLocation = [ IMSCC_CP_NAMESPACE, IMSCC_CP_SCHEMALOCATION, IMSCC_LOMMANIFEST_NAMESPACE, IMSCC_LOMMANIFEST_SCHEMALOCATION, IMSCC_LOMRESOURCE_NAMESPACE, IMSCC_LOMRESOURCE_SCHEMALOCATION ] if isinstance(self.root, imscp.CPElement): self.root.set_attribute( (xsi.XMLSCHEMA_NAMESPACE, 'schemaLocation'), string.join(schemaLocation, ' ')) def get_element_class(self, name): eClass = ManifestDocument.classMap.get( name, ManifestDocument.classMap.get((name[0], None), xmlns.XMLNSElement)) return eClass xmlns.map_class_elements(ManifestDocument.classMap, globals()) # xmlns.map_class_elements(ManifestDocument.classMap,imsmd) # xmlns.map_class_elements(ManifestDocument.classMap,imsqti) # Add other supported metadata schemas in here class ContentPackage(imscp.ContentPackage): ManifestDocumentClass = ManifestDocument class CommonCartridge(v1p0.CommonCartridge): ContentPackageClass = ContentPackage
self.LOMPerson = None self.LOMDate = None self.Description = None def get_children(self): if self.LOMPerson: yield self.LOMPerson if self.LOMDate: yield self.LOMDate if self.Description: yield self.Description for child in LRMElement.get_children(self): yield child class LOMClassification(LRMElement): XMLNAME = (IMSLRM_NAMESPACE, 'classification') classMap = {(IMSLRM_NAMESPACE, None): LRMElement} xmlns.map_class_elements(classMap, globals()) def get_element_class(name): ns, xmlname = name if ns in IMSLRM_NAMESPACE_ALIASES: ns = IMSLRM_NAMESPACE_ALIASES[ns] return classMap.get((ns, xmlname), classMap.get((ns, None), xmlns.XMLNSElement))
self.LOMDate = None self.Description = None def get_children(self): if self.LOMPerson: yield self.LOMPerson if self.LOMDate: yield self.LOMDate if self.Description: yield self.Description for child in LRMElement.get_children(self): yield child class LOMClassification(LRMElement): XMLNAME = (IMSLRM_NAMESPACE, 'classification') classMap = { (IMSLRM_NAMESPACE, None): LRMElement } xmlns.map_class_elements(classMap, globals()) def get_element_class(name): ns, xmlname = name if ns in IMSLRM_NAMESPACE_ALIASES: ns = IMSLRM_NAMESPACE_ALIASES[ns] return classMap.get((ns, xmlname), classMap.get((ns, None), xmlns.XMLNSElement))
pass # DataServiceVersion: This attribute MUST be in the data service # metadata namespace and SHOULD be present on a <edmx:DataServices> # element to indicate the version of the data service CSDL # annotations (attributes in the data service metadata namespace) # used by the document. # # The value of this attribute MUST be 1.0 unless a # "FC_KeepInContent" Customizable Feed annotation with a value equal # to false is present... In this case, the attribute value MUST be # 2.0. try: version = self.root.DataServices.get_attribute( core.DATA_SERVICE_VERSION) match = "1.0" for e in self.root.find_children_depth_first(edm.CSDLElement): try: if e.get_attribute(core.FC_KeepInContent) == "false": match = "2.0" break except KeyError: pass if version != match: raise edm.InvalidMetadataDocument( "Expected version %s, found %s" % (match, version)) return version except KeyError: return None xmlns.map_class_elements(Document.classMap, globals(), edm.NAMESPACE_ALIASES)