Hi!

Let's say that I have the following node-set type variable and for-each loop:

var $results := {
    <abc a="12" b="34" c="56"> {
        <klm k="78"> {
            <name n="9"> "foo";
            <name n="9"> "bar";
        }
    }
}

for-each ($results/abc) {
    copy-node {
        for-each (@*) {
            attribute name(.) {
                expr .;
            }
        }
    }
}

When I run this with traceoptions enabled, then I can see that "<abc
a="12" b="34" c="56"/>" is present in the output document. I guess
that this inner for-each loop, based on my example, expands to this:

copy-node {
    attribute "a" {
        expr 12;
    }
    attribute "b" {
        expr 34;
    }
    attribute "c" {
        expr 56;
    }
}

Now "copy-node" does its shallow copy and copies "abc" element node
and specified three attribute nodes to result tree. Am I correct? In
addition, why does copy-node run only once despite the fact that it is
in the for-each loop? Is it because copy-node discards all the child
elements of its current node and thus there are no more element
nodes(<klm>, <name>, <name> based on my example) to loop through?


thanks,
Martin
_______________________________________________
juniper-nsp mailing list juniper-nsp@puck.nether.net
https://puck.nether.net/mailman/listinfo/juniper-nsp

Reply via email to