|
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
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
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: (data..), (attribute-string...), John Sidlo | Thread | RE: (data..), (attribute-string...), John Sidlo |
| Texinfo output with SGML backend?, Tony Graham | Date | I need information about SGML to HT, miguel . mata |
| Month |