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
103 "STP is a data structure for well-formed XML documents.
105 @begin[Parsing and Serializing]{section}
106 To parse into STP, use an STP builder together with a function
107 generating SAX events:
109 @aboutfun{make-builder}
110 Serialize STP by sending SAX events for the tree to a sink:
114 @begin[Names and Namespace URIs]{section}
115 STP represents namespace-well-formed documents only. All functions
116 accepting names take a local-name and and a namespace URI as an argument.
117 Qualified names are accepted where it makes sense, and named nodes have
118 a namespace prefix that is taken into account for well-formedness checks.
120 There are two kinds of named nodes: @class{element} and @class{attribute}.
123 @aboutfun{local-name}
124 @aboutfun{namespace-uri}
125 @aboutfun{namespace-prefix}
126 For @code{element}, all of the above can be changed using SETF (subject
127 to well-formedness checks).
129 For attribute, @fun{local-name} can be changed directly, while URI and
130 prefix always have to be changed in the same step using
131 @fun{rename-attribute}.
133 A node's qualified name can be be queried:
135 @aboutfun{qualified-name}
137 @code{of-name} is convenient when searching for elements or attributes:
141 @begin[Subclasses of Node]{section}
142 All STP nodes have a common superclass.
145 Documents and elements can have children:
147 @aboutclass{parent-node}
148 @aboutclass{document}
150 Attributes belong to an @code{element}:
152 @aboutclass{attribute}
153 Other kinds of nodes:
156 @aboutclass{document-type}
157 @aboutclass{processing-instruction}
160 @begin[Creating nodes]{section}
161 Nodes are created using the following functions:
163 @aboutfun{make-attribute}
164 @aboutfun{make-comment}
165 @aboutfun{make-document}
166 @aboutfun{make-document-type}
167 @aboutfun{make-element}
168 @aboutfun{make-processing-instruction}
170 In addition, nodes can be copied including all their children:
174 @begin[Listing Child Nodes]{section}
175 Nodes have an optional parent node and can have children.
178 If a node has a @class{document} as its ancestor, it can be found using
179 the @fun{document} function.
182 Since the @code{parent} slot needs to be updated when children are added or
183 removed, the sequence of children is not exposed as a mutable Common
186 @aboutfun{list-children}
187 @aboutfun{map-children}
188 @aboutmacro{do-children}
189 The following DOM-like functions are also offered:
192 @aboutfun{first-child}
193 @aboutfun{last-child}
194 @aboutfun{previous-sibling}
195 @aboutfun{next-sibling}
196 A wide variety of sequence-related functions is offered that work
197 like the Common Lisp functions of the same name, but without the need
198 to call @fun{list-children} first:
200 @aboutfun{find-child}
201 @aboutfun{find-child-if}
202 @aboutfun{child-position}
203 @aboutfun{child-position-if}
204 @aboutfun{count-children}
205 @aboutfun{count-children-if}
206 @aboutfun{filter-children}
207 The functions listed above walk only across the direct children of the
208 parent node. In addition, the node hierarchy can be mapped recursively
209 using these functions:
211 @aboutfun{map-recursively}
212 @aboutmacro{do-recursively}
213 @aboutfun{find-recursively}
214 @aboutfun{filter-recursively}
217 @begin[Adding and Removing Child Nodes]{section}
218 While all nodes can be asked for their children, only documents and
219 elements permit actually adding children. (For all other nodes, the
220 sequence of children appears as empty.)
222 The most flexible function capable of changing the child nodes is
223 @fun{replace-children}. Perhaps more common is @fun{insert-child},
224 a specialized version for only one new child.
226 @aboutfun{replace-children}
227 @aboutfun{insert-child}
228 Various convenience functions are offered in addition:
230 @aboutfun{prepend-child}
231 @aboutfun{append-child}
232 @aboutfun{delete-child}
233 @aboutfun{delete-child-if}
234 @aboutfun{delete-nth-child}
235 @aboutfun{insert-child-before}
236 @aboutfun{insert-child-after}
237 @aboutfun{replace-child}
238 A node can also be deleted from its parent directly using @fun{detach}.
241 @fun{detach} also works for attributes.
244 @begin[Elements and their Attributes]{section}
245 In addition to their children, elements have attributes and \"extra
248 Attributes themselves are nodes and be accessed using these functions:
250 @aboutfun{add-attribute}
251 @aboutfun{remove-attribute}
252 @aboutfun{find-attribute-named}
253 @aboutfun{find-attribute-if}
254 @aboutfun{list-attributes}
255 @aboutfun{map-attributes}
256 @aboutmacro{with-attributes}
257 As a shortcut, the @fun{attribute-value} and its @code{setf} function
258 allow access to attribute values by name, without having to look up the
259 attribute node first:
261 @aboutfun{attribute-value}
262 There are three ways to declare a namespace: Using the name of the
263 element, using the name of one of its attributes, or using an \"extra
264 namespace\". A prefix can be looked up from any of these local
265 declarations. It is also possible to look up a namespace while taking
266 into account all declarations on parent elements.
268 @aboutfun{find-local-namespace}
269 @aboutfun{find-namespace}
270 Extra namespaces are needed only when a namespace must be declared even
271 though there is no element or attribute referencing it through its name.
272 For example, an attribute declared with type @code{QName} using
273 RelaxNG/XSD must reference a namespace in scope.
275 @aboutfun{add-extra-namespace}
276 @aboutfun{remove-extra-namespace}
277 @aboutfun{find-extra-namespace}
278 @aboutfun{map-extra-namespaces}
281 (defpackage :cxml-stp-impl
283 (:shadow
#:document
#:document-type
))