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

Subject: Re: (data..), (attribute-string...), (node-property...)
From: Brandon Ibach <bibach@xxxxxxxxxxxxxx>
Date: Thu, 20 Aug 1998 13:19:24 -0500 (CDT)
John Sidlo said:
> Sean, thank you for your repl(ies).  I believe your snippet illustrates how
> to obtain "bar", but what I was hoping for was how to obtain "foomore foo"
> from the <title>.  Of course, given that I can get "bar" I could always
> search for substring in the "foobarmore foo", but I was hoping for a more
> direct way to accomplish it.  There must be a more straightforward way to
> get this.
> > >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
   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:

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