RE: element content

Subject: RE: element content
From: "John Sidlo" <jsidlo@xxxxxxxxxxxxxxxxxx>
Date: Mon, 26 Oct 1998 10:39:04 -0500
I believe this is the answer to your question, (appeared 8/20/98 on the
dssslist)

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
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:
> [mailto:owner-dssslist@xxxxxxxxxxxxxxxx]On Behalf Of Josi Carlos Ramalho
> Sent: Monday, October 26, 1998 10:01 AM
> To: dssslist@xxxxxxxxxxxxxxxx
> Subject: element content
>
>
> Forgive for my silly question but I am going around in circles.
> I want the following:
> ...
>    (let* (target ???))
> ...
>
> I want ??? to be the current element content in string format so I can
> use in an expression like:
>
> 	... (literal target) ...
>
> I am sure there is a simple answer...
>
> thanks
> jcr


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


Current Thread