1
########################################################################
3
# File Name: DocumentType.py
5
# Documentation: http://docs.4suite.org/4DOM/DocumentType.py.html
8
WWW: http://4suite.org/4DOM e-mail: support@4suite.org
10
Copyright (c) 2000 Fourthought Inc, USA. All Rights Reserved.
11
See http://4suite.org/COPYRIGHT for license and copyright information
14
from xml.dom import Node
15
from DOMImplementation import implementation
16
from FtNode import FtNode
18
class DocumentType(FtNode):
19
nodeType = Node.DOCUMENT_TYPE_NODE
21
def __init__(self, name, entities, notations, publicId, systemId):
22
FtNode.__init__(self, None)
23
self.__dict__['__nodeName'] = name
24
self._entities = entities
25
self._notations = notations
26
self._publicId = publicId
27
self._systemId = systemId
28
#FIXME: Text repr of the entities
29
self._internalSubset = ''
31
### Attribute Methods ###
34
return self.__dict__['__nodeName']
36
def _get_entities(self):
39
def _get_notations(self):
40
return self._notations
42
def _get_publicId(self):
45
def _get_systemId(self):
48
def _get_internalSubset(self):
49
return self._internalSubset
51
### Overridden Methods ###
54
return "<DocumentType Node at %x: Name='%s' with %d entities and %d notations>" % (
61
### Internal Methods ###
63
# Behind the back setting of doctype's ownerDocument
64
# Also sets the owner of the NamedNodeMaps
65
def _4dom_setOwnerDocument(self, newOwner):
66
self.__dict__['__ownerDocument'] = newOwner
67
#self._entities._4dom_setOwnerDocument(newOwner)
68
#self._notations._4dom_setOwnerDocument(newOwner)
70
def _4dom_setName(self, name):
71
# Used to keep the root element and doctype in sync
72
self.__dict__['__nodeName'] = name
74
### Helper Functions For Cloning ###
76
def _4dom_clone(self, owner):
77
return self.__class__(self.name,
78
self.entities._4dom_clone(owner),
79
self.notations._4dom_clone(owner),
83
def __getinitargs__(self):
84
return (self.nodeName,
91
### Attribute Access Mappings ###
93
_readComputedAttrs = FtNode._readComputedAttrs.copy()
94
_readComputedAttrs.update({'name':_get_name,
95
'entities':_get_entities,
96
'notations':_get_notations,
97
'publicId':_get_publicId,
98
'systemId':_get_systemId,
99
'internalSubset':_get_internalSubset
103
_writeComputedAttrs = FtNode._writeComputedAttrs.copy()
104
_writeComputedAttrs.update({
107
# Create the read-only list of attributes
108
_readOnlyAttrs = filter(lambda k,m=_writeComputedAttrs: not m.has_key(k),
109
FtNode._readOnlyAttrs + _readComputedAttrs.keys())