Harald Oehlmann <
wort...@yahoo.de> writes:
> I have a WSDL file which has combined support for SOAP 1.1 and SOAP 1.2.
> I want basically remove all the SOAP 1.2 stupp which is in a distinct
> namespace.
>
> Is there an easy possibility to remove all nodes and their subnodes with
> tags in a given namespace ?
My picture of what you have and what you want and why you do want this
isn't very clear. (To start with: why to you want to remove that SOAP
1.2 nodes in the frist place? If you just care about the SOAP 1.1 nodes
and select them with correctly namespaced XPath expressions all nodes in
every other namespaces are not in your way.)
With
dom selectNodesNamespaces {soap12
http://use/the/correct/ns}
set soap12Nodes [$someNodeOrEvenTheDocCmdItself selectNodes //soap12:*]
you get the list of all element nodes in that namespace.
But if you want to remove all nodes in that namespace this list may not
be of much help for you (you may loop over them, geht the parent node
for every, do a [$parent removeNode $soap12node], but that may do a lot
of unnecessary work.
Are there nodes in other namespaces inside of subtrees with roots in the
SOAP 1.2 namespaces that you may want to preserve?
You could just remove the top most subtrees with SOAP 1.2 namespaced
roots. Something like (asuming a correct selectNodesNamespaces setting
as above or a -namespaces {foo bar baz boo} option to the selectNodes
method)
foreach node [$doc selectNodes //soap12:*[not(ancestor::soap12:*)]] {
set parent [$node parentNode]
if {$parent ne ""} {
# Only document element hasn't a parent node
$parent removeNode $node
}
}
That XPath expr should select any soap 1.2 node without a soap 1.2 node
in its ancestors up to the document element or in other words: all
top-most subtrees with soap 1.2 namespaced roots.
Example code guaranteed untested! Fix any stupid error as appropriate.