Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Use variables to get unique nodes

From: =?ISO-8859-1?Q?J=FCrgen_Kahrs?= <Juergen.KahrsDELETETHIS@------.-->
To: NULL
Date: 10/1/2004 8:10:00 PM
Rolf Kemper wrote:

> What I wnat to do is to get a set of distinct nodes.

What is "distinct" ? Unique within one TEST node ?
Or Unique within one Root node ?

I wrote a short xmlgawk script, which tries to
reproduce your results. The script even looks
readable to me. Half of it consists of printing
test results:

# distinct_nodes.awk
# comp.text.xml 2004-10-01
# Read all nodes of type pin and find the ones
# which have a unique name attribute.
# JK 2004-10-01

BEGIN {
  XMLMODE=1
  print "all pins of all test nodes ==>"
}

XMLSTARTELEM == "Pin" {
  count[XMLATTR["PinName"]] ++
  print XMLATTR["PinName"]
}

END {
  print "multiple pins  ==>"
  for (PinName in count) {
    if (count[PinName] > 1)
      print PinName, count[PinName]
  }
  print "unique pins ==>"
  for (PinName in count) {
    if (count[PinName] == 1)
      print PinName, count[PinName]
  }
}


> all pins of all test nodes ==> OK 
> A
> B
> B
> C
> X
> A
> D
> C
> X
> A
> 
> multiple pins  ==> OK 
> B
> A
> C
> X
> A
> 
> unique pins ==> NOT GOOD !! 
> B
> A
> C
> X
> A

The results I get are:
all pins of all test nodes ==>
A
B
B
C
X
A
D
C
X
A
multiple pins  ==>
A 3
B 2
C 2
X 2
unique pins ==>
D 1

> ( I expected B A C X )
> #################### End #################################

Why do you expect B A C X ?
No matter how I understand "distinct", I would not
call B A C X "distinct" pins.


BTW: Do the Electrical Engineers at NEC really use XML
for counting their beans .. errhhh pins .. ?


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent