For Programmers: Free Programming Magazines  


Home > Archive > Tcl > November 2006 > Re: multiple siblings, using tDOM to generate XML ... and eventually I arrive at a so









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: multiple siblings, using tDOM to generate XML ... and eventually I arrive at a so
jkj

2006-11-29, 7:08 pm

Thanks Christian, that works... the issue with building up a nested
string dynamically is that the newlines are being lost in calls to
concat. For example:
% set newline "\n"


% set test "teststring {"
teststring {
% set test [concat $test$newline " channel {"]
teststring { channel {

....I don't want to lose the newlines - at this point, I want $test to
contain:
teststring {
channel {

....so, in mucking around some more it is becoming clear to me that the
call I wish to make is "append" rather than "concat", as in:
% set newline "\n"


% set test "teststring {"
teststring {
% append test [append newline " channel {"]
teststring {
channel {

....brick-by-brick - Tcl syntax is a mind-warp. I'm sure I'll love it
with some more practice.
-Kevin


Christian Nassau wrote:
> You should probably leave out the extra quotes from your definition of
> the testscript, because those gives you the unwanted extra level of
> grouping. If you use just
>
> set teststring {
> channel {
> title { }
> description { }
> }
> }
>
> a plain
>
> $root appendFromScript $teststring
>
> ought to work.
>
> jkj wrote:
>
> --
> => Christian Nassau, http://www.nullhomotopie.de


Alan Anderson

2006-11-29, 7:08 pm

"jkj" <kevin@vexona.com> wrote:

> ...so, in mucking around some more it is becoming clear to me that the
> call I wish to make is "append" rather than "concat",..


[append] puts strings together. [concat] puts *lists* together. Since
you appear to want to work with a string, newlines and all, you don't
want [concat].

But the string you're building appears to be treated as a list at some
point, so I'm not sure why you would care about the newlines as opposed
to some other whitespace.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com