~vil/pydev/upstream

« back to all changes in this revision

Viewing changes to org.python.pydev.jython/Lib/xml/dom/DocumentType.py

  • Committer: Vladimír Lapáček
  • Date: 2006-08-30 18:38:44 UTC
  • Revision ID: vladimir.lapacek@gmail.com-20060830183844-f4d82c1239a7770a
Initial import of upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
########################################################################
 
2
#
 
3
# File Name:            DocumentType.py
 
4
#
 
5
# Documentation:        http://docs.4suite.org/4DOM/DocumentType.py.html
 
6
#
 
7
"""
 
8
WWW: http://4suite.org/4DOM         e-mail: support@4suite.org
 
9
 
 
10
Copyright (c) 2000 Fourthought Inc, USA.   All Rights Reserved.
 
11
See  http://4suite.org/COPYRIGHT  for license and copyright information
 
12
"""
 
13
 
 
14
from xml.dom import Node
 
15
from DOMImplementation import implementation
 
16
from FtNode import FtNode
 
17
 
 
18
class DocumentType(FtNode):
 
19
    nodeType = Node.DOCUMENT_TYPE_NODE
 
20
 
 
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 = ''
 
30
 
 
31
    ### Attribute Methods ###
 
32
 
 
33
    def _get_name(self):
 
34
        return self.__dict__['__nodeName']
 
35
 
 
36
    def _get_entities(self):
 
37
        return self._entities
 
38
 
 
39
    def _get_notations(self):
 
40
        return self._notations
 
41
 
 
42
    def _get_publicId(self):
 
43
        return self._publicId
 
44
 
 
45
    def _get_systemId(self):
 
46
        return self._systemId
 
47
 
 
48
    def _get_internalSubset(self):
 
49
        return self._internalSubset
 
50
 
 
51
    ### Overridden Methods ###
 
52
 
 
53
    def __repr__(self):
 
54
        return "<DocumentType Node at %x: Name='%s' with %d entities and %d notations>" % (
 
55
            id(self),
 
56
            self.nodeName,
 
57
            len(self._entities),
 
58
            len(self._notations)
 
59
            )
 
60
 
 
61
    ### Internal Methods ###
 
62
 
 
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)
 
69
 
 
70
    def _4dom_setName(self, name):
 
71
        # Used to keep the root element and doctype in sync
 
72
        self.__dict__['__nodeName'] = name
 
73
 
 
74
    ### Helper Functions For Cloning ###
 
75
 
 
76
    def _4dom_clone(self, owner):
 
77
        return self.__class__(self.name,
 
78
                              self.entities._4dom_clone(owner),
 
79
                              self.notations._4dom_clone(owner),
 
80
                              self._publicId,
 
81
                              self._systemId)
 
82
 
 
83
    def __getinitargs__(self):
 
84
        return (self.nodeName,
 
85
                self._entities,
 
86
                self._notations,
 
87
                self._publicId,
 
88
                self._systemId
 
89
                )
 
90
 
 
91
    ### Attribute Access Mappings ###
 
92
 
 
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
 
100
                               })
 
101
 
 
102
 
 
103
    _writeComputedAttrs = FtNode._writeComputedAttrs.copy()
 
104
    _writeComputedAttrs.update({
 
105
                                })
 
106
 
 
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())