|
91 | 91 |
|
92 | 92 | (defmethod sax:start-element |
93 | 93 | ((handler dom-builder) namespace-uri local-name qname attributes) |
94 | | - (check-type qname rod) ;catch recoder/builder mismatch |
| 94 | + (check-type qname rod) ;catch recoder/builder mismatch |
95 | 95 | (flush-characters handler) |
96 | 96 | (with-slots (document element-stack) handler |
97 | | - (let* ((nsp sax:*namespace-processing*) |
98 | | - (element (make-instance 'element |
99 | | - :tag-name qname |
100 | | - :owner document |
101 | | - :namespace-uri (when nsp namespace-uri) |
102 | | - :local-name (when nsp local-name) |
103 | | - :prefix (%rod (when nsp (cxml::split-qname (real-rod qname)))))) |
104 | | - (parent (car element-stack)) |
105 | | - (anodes '())) |
106 | | - (dolist (attr attributes) |
107 | | - (let ((anode |
108 | | - (if nsp |
109 | | - (dom:create-attribute-ns document |
110 | | - (sax:attribute-namespace-uri attr) |
111 | | - (sax:attribute-qname attr)) |
112 | | - (dom:create-attribute document (sax:attribute-qname attr)))) |
113 | | - (text |
114 | | - (dom:create-text-node document (sax:attribute-value attr)))) |
115 | | - (setf (slot-value anode 'specified-p) |
116 | | - (sax:attribute-specified-p attr)) |
117 | | - (setf (slot-value anode 'owner-element) element) |
118 | | - (dom:append-child anode text) |
119 | | - (push anode anodes))) |
| 97 | + (let* ((parent (car element-stack)) |
| 98 | + (nsp sax:*namespace-processing*) |
| 99 | + (prefix (%rod (when nsp |
| 100 | + (cxml::split-qname (real-rod qname))))) |
| 101 | + (map (make-instance 'attribute-node-map |
| 102 | + :element-type :attribute |
| 103 | + :owner document)) |
| 104 | + (element (make-instance 'element |
| 105 | + :tag-name qname |
| 106 | + :attributes map |
| 107 | + :owner document |
| 108 | + :namespace-uri (when nsp namespace-uri) |
| 109 | + :local-name (when nsp local-name) |
| 110 | + :prefix prefix))) |
| 111 | + ;; Link to parent |
120 | 112 | (setf (slot-value element 'parent) parent) |
121 | 113 | (fast-push element (slot-value parent 'children)) |
122 | | - (let ((map |
123 | | - (make-instance 'attribute-node-map |
124 | | - :items anodes |
125 | | - :element-type :attribute |
126 | | - :element element |
127 | | - :owner document))) |
128 | | - (setf (slot-value element 'attributes) map) |
129 | | - (dolist (anode anodes) |
130 | | - (setf (slot-value anode 'map) map))) |
| 114 | + ;; Link map and create attributes |
| 115 | + (flet ((make-attribute (attr) |
| 116 | + (let* ((qname (sax:attribute-qname attr)) |
| 117 | + (namespace-uri (sax:attribute-namespace-uri attr)) |
| 118 | + (value (sax:attribute-value attr)) |
| 119 | + (specified-p (sax:attribute-specified-p attr)) |
| 120 | + (node (if nsp |
| 121 | + (dom:create-attribute-ns |
| 122 | + document namespace-uri qname) |
| 123 | + (dom:create-attribute document qname))) |
| 124 | + (text (dom:create-text-node document value))) |
| 125 | + (setf (slot-value node 'specified-p) specified-p |
| 126 | + (slot-value node 'owner-element) element |
| 127 | + (slot-value node 'map) map) |
| 128 | + (dom:append-child node text) |
| 129 | + node))) |
| 130 | + (setf (slot-value map 'element) element |
| 131 | + (slot-value map 'items) (mapcar #'make-attribute attributes))) |
131 | 132 | (push element element-stack)))) |
132 | 133 |
|
133 | 134 | (defmethod sax:end-element ((handler dom-builder) namespace-uri local-name qname) |
|
0 commit comments