RE: Counting Nodes

Subject: RE: Counting Nodes
From: "Maltby, David G" <david.g.maltby@xxxxxxxx>
Date: Thu, 24 Feb 2000 16:41:24 -0500
> -----Original Message-----
> From: Brandon Ibach [mailto:bibach@xxxxxxxxxxxxxx]
> Sent: Thursday, February 24, 2000 4:23 PM
> To: dssslist@xxxxxxxxxxxxxxxx
> Subject: Re: Counting Nodes
> 
>    Okay, I have to theorize here, a bit, because I don't have the DTD
> you're using (in addition to the fact that I don't really know the
> SGML whitespace handling rules very well).  The 13 nodes are: The
> <text> containing "List Item 1", the newline and two spaces following,
> the <text> containing the sublist, the two spaces at the beginning of
> the line following the closing tag of that, the <text> containing
> "List Item 2", the newline and two spaces following, the <text>
> containing "List Item 3", and the following newline.  That should be a
> total of 13, and should match the numbering you're getting.
>    And, for the record, the problem (or "confusion", perhaps) here is
> that, I expect, the "text" element is declared to have mixed content
> in order to allow either the text of item or a list of other <text>s,
> thus the mixture of elements and data-chars in the node-list you're
> getting from (siblings).

Yes, Yes, Yes!  The content model, in part, is (#PCDATA | TEXT)+. And there
are spaces and newlines between the tags. I was just about to repost another
question on this line, and here you have answered it.  I can not type as
fast as you guys think.

>    So, the solution is to just include a clause in your (cond) to
> check the class of each node and ignore it completely (including *not*
> incrementing the counter) if it isn't an element.  And while you're
> modifying that procedure, you'll want to drop the parens around "cnt"
> in the clause with (node-list-empty?).  This clause should,
> theoretically, never fire, but if it did, it would try to execute cnt,
> which is not a procedure.

I am glad to know that there is a method to exclude these nodes.

>    I believe I have a procedure around here somewhere that works like
> (debug) for node-lists, dumping out quite a bit of information about
> their members but returning the node-list unscathed.  Let me know if
> you're interested, and I'll dig it up and make sure it's in working
> order. :)

Of course, I am interested but I hate to have you go to any trouble.  If
your going to do it any way, perhaps you could pass such a debug to Tony for
inclusion in the Library.

Best Regards, David


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread