Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TDOM Delete the nodes in a given namespace

53 views
Skip to first unread message

Harald Oehlmann

unread,
Nov 10, 2017, 3:32:52 AM11/10/17
to
Hello Rolf, hello TDOM experts,

well, here is the always learning sort of TCLWS maintainer with a new
challenge.

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 ?

Thank you for any thoughts,
Harald

Rolf Ade

unread,
Nov 10, 2017, 12:07:39 PM11/10/17
to
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.

Harald Oehlmann

unread,
Nov 10, 2017, 12:08:12 PM11/10/17
to
Gerald wrote me by private mail that this is already implemented by a
XSLT transformation.

I tested it, it works.

So thank you all,
Harald

Rolf Ade

unread,
Nov 10, 2017, 12:19:29 PM11/10/17
to

Harald Oehlmann <wort...@yahoo.de> writes:
> Am 10.11.2017 um 09:32 schrieb Harald Oehlmann:
>> 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 ?
>
> Gerald wrote me by private mail that this is already implemented by a
> XSLT transformation.

Sounds a bit to use a sledgehammer to crack a nut. But as said I've no
clear picture about your problem.

> I tested it, it works.

And at the end: Whatever works for you is probably fine.

Harald Oehlmann

unread,
Nov 10, 2017, 12:21:34 PM11/10/17
to
Rolf,

thank you for the great proposal.
As it turned out by private mail with Gerald, that this is solved by an
XSLT transformation.
I will look into the details of this on Monday, no idea what this is...

Thank you,
Harald

Am 10.11.2017 um 18:07 schrieb Rolf Ade:
> 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.)

Well, I have a pice of code which works with Soap 1.1, so I thougt, get
all soap 1.2 out of the way and it will work and I don't have to
understand the Code...

>
> 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.

I don't care to much. WSDL parsing is only done once in the
initialisation phase. So performance is not an issue.

>
> Are there nodes in other namespaces inside of subtrees with roots in the
> SOAP 1.2 namespaces that you may want to preserve?

No

> 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.

Thank you. That was my idea and what I asked for.

Thank you,
Harald

Harald Oehlmann

unread,
Nov 10, 2017, 12:31:44 PM11/10/17
to
Am 10.11.2017 um 18:19 schrieb Rolf Ade:
> Sounds a bit to use a sledgehammer to crack a nut. But as said I've no
> clear picture about your problem.

Gerald wrote that the purpose is just to delete nodes in namespaces.
So I might look into it and modify it to use a swiss knife instead a
sledgehammer. Not the best tool but also fun and less waste in the room.

thank you and enjoy the week-end,
Harald

Harald Oehlmann

unread,
Nov 14, 2017, 5:55:41 AM11/14/17
to
Nothing done so far, so parked in a ticket:
http://core.tcl.tk/tclws/tktview/40456c18c9c49cc97ba3ef731c5c92f2605620cc

Thank you all,
Harald
0 new messages