Re: (dsssl) siblings

Subject: Re: (dsssl) siblings
From: Brandon Ibach <bibach@xxxxxxxxxxxxxx>
Date: Tue, 26 Feb 2002 14:54:57 -0600
Quoting Dave Pawson <DaveP@xxxxxxxxxxxxxxxxxxxxxxx>:
> Does the meaning of siblings in a grove equate with the definition
> in an xml document model?
> 
> <doc>
> <sect1 id="sect1id">
>      <head>This is a heading</head>
>      <p>This is text</p>
>      <p>This is <em>bold</em></p>
>      <p>This is <strong>strong</strong></p>
>      <sect2 id="sect2id" att2="sect2attrib">
>        <head>Section 2 heading</head>
>        <p>Another paragraph  <anchor id="anchid">content</anchor></p>
>       <sect3><head>Section 3 heading</head>
> 	<special id="spec">Content in section 3</special>
>        </sect3>
>      </sect2>
>    </sect1>
> </doc>
> 
> For element special:
>   (literal "Siblings: " ( number->string (node-list-length (siblings))))
> 
> shows a count of 13, which simply doesn't make sense to me.
>  From the spec
> 4.29 siblings (of a node)
> The other nodes in the grove that occur in the value of the 
> origin-to-subnode relationship property of the origin of the node.
> 
> I interpret this as being the 'depth in the tree' relationship,
> according to which the sibling count should be 0.
> 
Hi, Dave...
   First of all, how do you have (siblings) defined?  Using the
definition from the copy of the DSSSL procedure library you have on
your site, I get a value of 2 for the "special" element, which looks
correct, as that definition returns the element itself along with the
element's siblings, so it is counting the <head> and <special>
elements.
   Perhaps the count of 13 includes character nodes for the whitespace
within the <sect3>?  Not having the DTD you used, I may have gotten
different results.  Try replacing the (literal "Siblings: " ...) line
you have with (debug-nl (siblings)).  Here's (debug-nl):

(define (debug-nl #!optional (nl (current-node)))
  (let loop ((n nl) (r (literal "Node-list:" cr)))
    (if (node-list-empty? n) r
        (loop (node-list-rest n)
              (sosofo-append r
              (let* ((nd (node-list-first n)) (c (node-property 'classnm nd)))
                (cond
                  ((equal? 'element   c) (literal "Element: " (gi nd) cr))
                  ((equal? 'data-char c)
                   (literal "Char:    |"
                            (string (node-property 'char nd)) "|" cr))
                  (else (literal "Node:    " (symbol->string c) cr)))))))))

   This will give you a listing of what's returned from (siblings).
More detail could, of course, be added to what it generates.

-Brandon :)

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

Current Thread
  • (dsssl) siblings
    • Dave Pawson - Tue, 26 Feb 2002 01:22:11 -0500 (EST)
      • Brandon Ibach - Tue, 26 Feb 2002 15:51:33 -0500 (EST) <=
      • <Possible follow-ups>
      • DPawson - Wed, 27 Feb 2002 03:19:38 -0500 (EST)