Hi, On Mon, 2005-05-16 at 18:12 +0200, cazic gmx net wrote:
Hi,
Time for a next step.
I attached the current sketch of an adopting mechanism. It's not
tested - just compiles.
It includes an initial on-the-fly reconciliation mechanism which
could be adjusted for different purposes per option.
The current options are:
(@node == the to-be-adopted node
@parent == the *new* parent node of @node)
- If a ns-decl was not found in @node's branch by pointer comparison:
- Option: "reconciliate-to-self"
Additionally to @parent's branch, this will try to search in
@node's branch when searching for an equal ns-name.
This should be disabled if one knows that @node's branch was
in a namespace normalized state previously (like when the doc-tree
was parsed and not modified by API operations) - a pointer
comparison will be sufficient in this case.
- Option: "exact-prefix"
Additionally to an ns-name this will try to find an equal
ns-prefix.
If no appropriate ns-prefix/name was found it will try
to create a ns-decl on the _nearest_ ancestor element. This follows
the spirit of W3C's namespace normalization, which adds or changes
the _nearest_ ns-decls_ when a specific namespace binding is
needed.
The mechanism here will eventually fail, since the desired prefix
might be already declared and in Libxml2 we cannot simply change
the ns-name of a ns-decl (since they are referenced). So, in
contrast to W3C's way, we will fall back to a search _without_ the
"exact-prefix" option for this node.
If an appropriate ns-decl was not found, it will declare a new namespace
on:
- if @parent != NULL, and @parent has an element node in the
ancestor-or-self axis, then on @parent's top-most element node.
- if @parent == NULL, then on the "oldNs" field of the destination
document-node. This is important if @node is an attribute node.
- Whether to user @parent's top-most element node as the anchor for new
ns-decls, or @node's nearest element node could be set per option as
well. It's not in yet.
- I still didn't use a hash for storing the ns-decls, since I needed
some additional information to be stored with each ns-decl. Maybe a hash
is still doable, dunno.
- Hope I made some progress in the string dict aware assignment of
values.
- I added back the @sourceDoc argument, since even if @node->doc == NULL
is not a problem, it appeared to me that we cannot detect XIncluded
nodes without an explicit source document.
XInclude start/end nodes are handles like element-nodes - OK?
XIncluded nodes are skipped and currently detected only by
(@node->doc ! = @cur->doc) - OK?
- Reconciliation to xmlns="" or xmlns:foo="" is avoided.
- Tried to handle the XML namespace.
Greetings,
Kasimier
Attachment:
xmlDOMWrapAdaptNode-souce.txt
Description: Text document