![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: Use variables to get unique nodes >Thread Next - Re: Use variables to get unique nodes Re: Use variables to get unique nodesTo: NULL Date: 10/2/2004 1:53:00 AM Hi Jürgen,
thank you for zour feedback.
Let me explain it once again, because my text was a bit weak.
What I need is a list of pins which occour more than once.
As a small hurdle I have to do some preselection by some other
properties before. Therefore the TestNodes.
So, the output should be the opposit of yours.
I have not tried the code provided by Marrow yet, but it explains
somehow what I have done wrong.
However, can you drop me some lines on xmlgawk ?
Can I use this within MSXML4 processor ?
How about schema check ?
As you stated, YES , the example is like counting some beans, but just
for the sake of demonstration. It addresses a very tiny problem of an
5M mixed data set. So my real world is a farm of beans , fruits ,
nuts, vegitables and many other things.
Myself is just creating different dishes out of it. XLST in
combination with XPATH is a great help, as I have to present the same
dish in differrent restaurants (HTML , Text , Exel , Spice ) too.
Finally, just for your valid comment and interest, we do a lot of PERL
scripting usually.
Thanks a lot
Rolf
Jürgen Kahrs <Juergen.KahrsDELETETHIS@v...> wrote in message news:<2s5ko5F1h3sv8U1@u...>...
> 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 .. ?
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
