question

dclaar avatar image
dclaar Suspended asked ericnute edited

descending xpath tree?

I want to dump out part of the Data tree.

I've tried variations on:

foreach child [xpathEval $node/*]

 

where $node is "/data", but that seems to get me the values, not the names.

 

Similarly, [get /data] just gives me the values of the children of data, not the names.

iTestxpath
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

dclaar avatar image
dclaar Suspended answered dclaar Suspended posted

If I want to enumerate attributes, what's the xpath?

set attrcount [xpathEval count($node/*\[$n\]/attribute::*)]

for {set a 1} {$a <= $attrcount} {incr a}

set attrname [xpathEval name($node/*\[$n\]/attribute::*/@*\[$a\])]

 

The above doesn't work. It finds the $n'th node, but not the $a'th attribute.

 

I've tried various combinations, but haven't hit on the right one yet.

4 comments
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

dclaar avatar image dclaar commented ·

Got it! Here's a test case to dump out your /data stack. Be careful, though: If you set max too big, you're going to get a ton of data!

 

1 Like 1 ·
dump_param.fftc (14.0 KiB)
KumarS avatar image KumarS dclaar commented ·
Another thing to be careful about is that this structure is subject to change from release to release. So you can use it for debugging - but do not use it to build your infrastructure.
0 Likes 0 ·
dclaar avatar image dclaar dclaar commented ·

There are some issues with my script: It doesn't pass attributes correctly, so things get out of hand rather quickly. I can't delete it, so I'll issue this warning, and put out a new version when I get it working. Right now I'm having issues with

 

Unable to evaluate "set nodecount [xpathEval count($node/*)]" : Invalid query count(/data/parameters/testcase[@pt:description=Name of testcase to run and @pt:source=comp.ffpt]/*)

 

Now, this is a bit deceiving, because I'm not sure if there are really single quotes there or not. I call the routine with:

 

dump_param level 3 node=/data/parameters/testcase[@pt:description='Name of testcase to run' and @pt:source='comp.ffpt']

And I've verified that the quotes are really there.

Message Edited by dclaar on 02-25-2009 10:12 PM
0 Likes 0 ·
dclaar avatar image dclaar dclaar commented ·

Here's one that works better. Bear in mind, it can still churn for a long time if you make the level too deep. If there's any recursion in /data, you could get stuck. Maybe the next step is to check for recursion? ...no promises there.

 

I've also added a parameter -find, which takes a regular expression. If you give this parameter, then only nodes matching the RE will be displayed.

0 Likes 0 ·
dump_param.fftc (17.1 KiB)
KumarS avatar image
KumarS answered KumarS posted
I do not think there is any command in iTest which will dump the XML tree of the "heap". You can only get values for various nodes. You can see part of the heap (parameters) in the raw xml of the test report. It can be considered a feature request.
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.