[REBOL] Re: building a dynamic path to elements in block
From: joel:neely:fedex at: 1-Nov-2000 6:46
Hi, Gary,
Yes, paths can be "interesting"! They are aggressively evaluated
and don't have quite as much freedom in compsition as one might
expect.
[rebol-bounce--rebol--com] wrote:
> for example
> [ [ 1999.01.0161 book=O poem=1 line=1 Greek] [ 1999.01.0162 book=O poem=1
> line=1 English ] ]
>
> the number of div-titles varies from document to document, but I want to
> dynamically grab them when rebuilding the xml.doc. Here's a stripped down bit
> of test code:
>
> ******code starts here*******
> div-count: ( length? structure-block/1 ) - 3
>
> for count 2 ( div-count + 1 ) 1 [
> temp-path: join 'structure-block/1["/"count]
> to-path temp-path
> print temp-path
> ]
> ******code ends here**********
To fix the immediate path-syntax problem, Try this instead
print structure-block/1/:count
> It gives me something like this
>
> *****example output******
> 1999.01.0161 book=O poem=1 line=1 Greek / 2
> 1999.01.0161 book=O poem=1 line=1 Greek / 3
> *****example output ends here******
>
> whereas I was expecting something like
>
> *****example output******
> book=O
> poem=1
> *****example output ends here******
You're getting (the value of structure-block/1) followed by "/" and
the value of count, where it appears that you wanted the value of
(structure-block/1/ followed by the value of count).
However, my curiousity is killing me... You wrote
> I've been reverse engineering a large collection of html docs
> into xml and I've come across a problem that I just can't seem to
> get my head around in REBOL.
>
> I've got a block that looks something like this
> [ [ id
> div-title1
> div-title2
> line-or-paragraph-number
> language
> ] [
> ..... as above
> ]
> .... any number
> ]
>
> for example
> [ [ 1999.01.0161 book=O poem=1 line=1 Greek]
> [ 1999.01.0162 book=O poem=1 line=1 English ] ]
I can't figure out how your block relates to XML. It isn't the output
from parse-xml, it doesn't correspond to XML by replacing the block
brackets with tag brackets, and it isn't literal REBOL either...
>> structure-block: [ [ 1999.01.0161 book=O poem=1 line=1 Greek]
[ [ 1999.01.0162 book=O poem=1 line=1 English ] ]
** Syntax Error: Invalid tuple -- 1999.01.0161.
** Where: (line 1) structure-block: [ [ 1999.01.0161 book=O poem=1
line=1 Greek]
If you can provide a few more clues, I might be able to give you some
more useful suggestions than just the minor syntax check above.
-jn-