4 (:export
#:*check-uri-syntax
*
65 #:find-attribute-named
72 #:find-local-namespace
73 #:find-extra-namespace
74 #:map-extra-namespaces
76 #:remove-extra-namespace
87 #:processing-instruction
88 #:make-processing-instruction
104 "STP is a data structure for well-formed XML documents.
106 @begin[Parsing and Serializing]{section}
107 To parse into STP, use an STP builder together with a function
108 generating SAX events:
110 @aboutfun{make-builder}
111 Serialize STP by sending SAX events for the tree to a sink:
115 @begin[Names and Namespace URIs]{section}
116 STP represents namespace-well-formed documents only. All functions
117 accepting names take a local-name and and a namespace URI as an argument.
118 Qualified names are accepted where it makes sense, and named nodes have
119 a namespace prefix that is taken into account for well-formedness checks.
121 There are two kinds of named nodes: @class{element} and @class{attribute}.
124 @aboutfun{local-name}
125 @aboutfun{namespace-uri}
126 @aboutfun{namespace-prefix}
127 For @code{element}, all of the above can be changed using SETF (subject
128 to well-formedness checks).
130 For attribute, @fun{local-name} can be changed directly, while URI and
131 prefix always have to be changed in the same step using
132 @fun{rename-attribute}.
134 A node's qualified name can be be queried:
136 @aboutfun{qualified-name}
138 @code{of-name} is convenient when searching for elements or attributes:
142 @begin[Subclasses of Node]{section}
143 All STP nodes have a common superclass.
146 Documents and elements can have children:
148 @aboutclass{parent-node}
149 @aboutclass{document}
151 Attributes belong to an @code{element}:
153 @aboutclass{attribute}
154 Other kinds of nodes:
157 @aboutclass{document-type}
158 @aboutclass{processing-instruction}
161 @begin[Creating nodes]{section}
162 Nodes are created using the following functions:
164 @aboutfun{make-attribute}
165 @aboutfun{make-comment}
166 @aboutfun{make-document}
167 @aboutfun{make-document-type}
168 @aboutfun{make-element}
169 @aboutfun{make-processing-instruction}
171 In addition, nodes can be copied including all their children:
175 @begin[Listing Child Nodes]{section}
176 Nodes have an optional parent node and can have children.
179 If a node has a @class{document} as its ancestor, it can be found using
180 the @fun{document} function.
183 Since the @code{parent} slot needs to be updated when children are added or
184 removed, the sequence of children is not exposed as a mutable Common
187 @aboutfun{list-children}
188 @aboutfun{map-children}
189 @aboutmacro{do-children}
190 The following DOM-like functions are also offered:
193 @aboutfun{first-child}
194 @aboutfun{last-child}
195 @aboutfun{previous-sibling}
196 @aboutfun{next-sibling}
197 A wide variety of sequence-related functions is offered that work
198 like the Common Lisp functions of the same name, but without the need
199 to call @fun{list-children} first:
201 @aboutfun{find-child}
202 @aboutfun{find-child-if}
203 @aboutfun{child-position}
204 @aboutfun{child-position-if}
205 @aboutfun{count-children}
206 @aboutfun{count-children-if}
207 @aboutfun{filter-children}
208 The functions listed above walk only across the direct children of the
209 parent node. In addition, the node hierarchy can be mapped recursively
210 using these functions:
212 @aboutfun{map-recursively}
213 @aboutmacro{do-recursively}
214 @aboutfun{find-recursively}
215 @aboutfun{filter-recursively}
218 @begin[Adding and Removing Child Nodes]{section}
219 While all nodes can be asked for their children, only documents and
220 elements permit actually adding children. (For all other nodes, the
221 sequence of children appears as empty.)
223 The most flexible function capable of changing the child nodes is
224 @fun{replace-children}. Perhaps more common is @fun{insert-child},
225 a specialized version for only one new child.
227 @aboutfun{replace-children}
228 @aboutfun{insert-child}
229 Various convenience functions are offered in addition:
231 @aboutfun{prepend-child}
232 @aboutfun{append-child}
233 @aboutfun{delete-child}
234 @aboutfun{delete-child-if}
235 @aboutfun{delete-nth-child}
236 @aboutfun{insert-child-before}
237 @aboutfun{insert-child-after}
238 @aboutfun{replace-child}
239 A node can also be deleted from its parent directly using @fun{detach}.
242 @fun{detach} also works for attributes.
245 @begin[Elements and their Attributes]{section}
246 In addition to their children, elements have attributes and \"extra
249 Attributes themselves are nodes and be accessed using these functions:
251 @aboutfun{add-attribute}
252 @aboutfun{remove-attribute}
253 @aboutfun{find-attribute-named}
254 @aboutfun{find-attribute-if}
255 @aboutfun{list-attributes}
256 @aboutfun{map-attributes}
257 @aboutmacro{with-attributes}
258 As a shortcut, the @fun{attribute-value} and its @code{setf} function
259 allow access to attribute values by name, without having to look up the
260 attribute node first:
262 @aboutfun{attribute-value}
263 There are three ways to declare a namespace: Using the name of the
264 element, using the name of one of its attributes, or using an \"extra
265 namespace\". A prefix can be looked up from any of these local
266 declarations. It is also possible to look up a namespace while taking
267 into account all declarations on parent elements.
269 @aboutfun{find-local-namespace}
270 @aboutfun{find-namespace}
271 Extra namespaces are needed only when a namespace must be declared even
272 though there is no element or attribute referencing it through its name.
273 For example, an attribute declared with type @code{QName} using
274 RelaxNG/XSD must reference a namespace in scope.
276 @aboutfun{add-extra-namespace}
277 @aboutfun{remove-extra-namespace}
278 @aboutfun{find-extra-namespace}
279 @aboutfun{map-extra-namespaces}
282 (defpackage :cxml-stp-impl
284 (:shadow
#:document
#:document-type
)
285 (:import-from
:xpath-protocol
#:define-default-method
))