RE: (data..), (attribute-string...), (node-property...)

Subject: RE: (data..), (attribute-string...), (node-property...)
From: "John Sidlo" <jsidlo@xxxxxxxxxxxxxxxxxx>
Date: Thu, 20 Aug 1998 15:43:17 -0400
A-Hahh!

Many thanks to Brandon Ibach for the following solution, and accompanying
lucid explanation which significantly improved my understanding of dsssl.

If you understand why, given the nodelist nl for the structure

<title>1234<footnote>x</footnote>5</title>

the (node-list-length nl) is 6, and not 1 or 5, then you probably don't need
to bother reading Brandon's explanation.  Otherwise, have a look!

ps - Daniel Speck also provided the correct solution - thanks to all who
responded

> -----Original Message-----
> From: owner-dssslist@xxxxxxxxxxxxxxxx
> [mailto:owner-dssslist@xxxxxxxxxxxxxxxx]On Behalf Of Brandon Ibach
> Sent: Thursday, August 20, 1998 2:19 PM
> To: dssslist@xxxxxxxxxxxxxxxx
> Subject: Re: (data..), (attribute-string...), (node-property...)
>
>
> John Sidlo said:
...
> > > >In Jade I am trying to extract the data from a nodelist representing:
> > >
> > > ><title>foo<footnote>bar</footnote>more foo</title>
> > >
> > > >The dsssl expression (data nl) returns (correctly) "foobarmore foo";
> > > >I want to extract "foomore foo".  I've tried
> (attribute-string "data" nl)
> > > >and (node-property 'data nl), but the property "data"
> doesn't seem to be
> > > >defined.
> > >
> > > >Can someone suggest a way to remove the children from <title>,
> > > >or otherwise extract this?
> > >
>    Here's a fairly simple method.  First, the concept...  The
> following, when grovified, will produce nodes of two classes:
>
> 	<title>foo<footnote>bar</footnote>more foo</title>
> 	^------***                        ********-------^
> 	          ^---------***----------^
>
>    The ^--...--^'s are element nodes, with ... representing the
> children of the node.  Each * is a data-char node.  These are what
> you're interested in, but only the ones in the first row, which are
> the data-char nodes that are direct children of the "title" element
> node.
>    So, in processing the title node, you'll want to generate a
> nodelist of title's children via a (children) call, then pass that to
> a function which will filter out any non-data-char nodes.  Fortunately,
> the DSSSL standard includes such a function, and Jade implements it.
>    The following accepts a node (singleton node list, to be
> technical) of type "element", and returns a string consisting of the
> plain text which is the immediate content (ie, not within any children
> elements) of that node.
>
> (define element-data (lambda (nl)
>   (data (select-by-class (children nl) 'data-char))))
>
>    Here's an example using the SGML backend to just spit out the data.
>
> (element TITLE (make formatting-instruction
>                  data: (element-data (current-node))))
>
> -Brandon :)
>
>
>  DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist
>


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


Current Thread
  • Re: (data..), (attribute-string...), (node-property...), (continued)
    • Toby Speight - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id MAA06334Thu, 20 Aug 1998 12:47:31 -0400 (EDT)
    • shennessy - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id LAA19018Wed, 19 Aug 1998 11:52:00 -0400 (EDT)
      • John Sidlo - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id QAA20986Wed, 19 Aug 1998 16:15:47 -0400 (EDT)
        • Brandon Ibach - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id OAA12286Thu, 20 Aug 1998 14:22:27 -0400 (EDT)
        • John Sidlo - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id PAA16334Thu, 20 Aug 1998 15:52:02 -0400 (EDT) <=
    • shennessy - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id MAA22738Wed, 19 Aug 1998 12:42:43 -0400 (EDT)