Tclxml question 
Author Message
 Tclxml question

Looks like this never made it out:

I just downloaded tclxml and I'm testing it out. I'm using the Tcl parser
and I've a question: how do you determine the environment of a CDATA string?
i.e which element it's part of, etc? Is that supposed to be the programmer's
job or are there facilities that I haven't figured out?

L

--
MY EMAIL ADDRESS HAS CHANGED --> UPDATE YOUR ADDRESSBOOK

Laurent Duperval                   "Montreal winters are an intelligence test,
Netergy Networks - Java Center            and we who are here have failed it."
Phone: (514) 282-8484 ext. 228                                   -Doug Camilli



Fri, 07 Mar 2003 03:00:00 GMT  
 Tclxml question

Quote:

> I just downloaded tclxml and I'm testing it out. I'm using the Tcl parser
> and I've a question: how do you determine the environment of a CDATA string?
> i.e which element it's part of, etc? Is that supposed to be the programmer's
> job or are there facilities that I haven't figured out?

That's the application's job, if it cares.  The application must set
a callback for the element start and end (-elementstartcommand and
-elementendcommand resp.) in order to know the context of the
character data.

Alternatively, you can use TclDOM to walk a tree instead.  The parent
node of the textNode will be its context.

Cheers,
Steve Ball

--
Steve Ball            |   Swish XML Editor    | Training & Seminars
Zveno Pty Ltd         |   Web Tcl Complete    |      XML XSL
http://www.zveno.com/ |    TclXML TclDOM      | Tcl, Web Development

Ph. +61 2 6242 4099   | Mobile (0413) 594 462 | Fax +61 2 6242 4099



Sat, 08 Mar 2003 11:27:06 GMT  
 Tclxml question

Quote:

>> I just downloaded tclxml and I'm testing it out. I'm using the Tcl parser
>> and I've a question: how do you determine the environment of a CDATA string?
>> i.e which element it's part of, etc? Is that supposed to be the programmer's
>> job or are there facilities that I haven't figured out?

> That's the application's job, if it cares.  The application must set
> a callback for the element start and end (-elementstartcommand and
> -elementendcommand resp.) in order to know the context of the
> character data.

That's pretty much what I've been doing. But I find my way of doing things
inelegant, which is ther reason I asked the question originally:

proc elementFound {args} {
        #puts "Element: $args"

Quote:
}

proc elementEnd {name args} {
        global filename
        global cdata
        if [string equal resource-datafile $name] {
                set filename(data/$cdata.scr) $::fileFound([file exists ../data/$cdata.scr])
        }
        # puts "Element end: $args"

Quote:
}

proc cdata {args} {
        global cdata
        set cdata $args

Quote:
}
> Alternatively, you can use TclDOM to walk a tree instead.  The parent
> node of the textNode will be its context.

Maybe I'll lok at that.

Thanks,

L

--
MY EMAIL ADDRESS HAS CHANGED --> UPDATE YOUR ADDRESSBOOK

Laurent Duperval                 "Montreal winters are an intelligence test,
                                         and we who are here have failed it."

Penguin Power!         ***Nothing I say reflects the views of my employer***



Sun, 09 Mar 2003 03:00:00 GMT  
 Tclxml question

Quote:

> That's pretty much what I've been doing. But I find my way of doing things
> inelegant, which is ther reason I asked the question originally:

I am (trying to find the time to) developing higher-level APIs.
One need that stands out is XPath, so you can do something like:

xml::switch $xmldata {
  resource-datafile {
    set filename [xpath::select .]
  }

Quote:
}

'xmlswitch' is something I just made up.  The idea is that it acts like
a switch command, only the data being switched over is XML and the case
statements each specify an XPath location path that triggers the case
statement command.  'xpath::select' would evaluate a location path,
where the context is the node selected by the case statement, and
return the result (in this case, the string value of the current node).

Quote:
> proc elementFound {args} {
>         #puts "Element: $args"
> }

> proc elementEnd {name args} {
>         global filename
>         global cdata
>         if [string equal resource-datafile $name] {
>                 set filename(data/$cdata.scr) $::fileFound([file exists ../data/$cdata.scr])
>         }
>         # puts "Element end: $args"
> }

> proc cdata {args} {
>         global cdata
>         set cdata $args
> }

Gotcha: the character data is always the first argument,
so this should be 'set cdata [lindex $args 0]'.

HTHs,
Steve Ball

--
Steve Ball            |   Swish XML Editor    | Training & Seminars
Zveno Pty Ltd         |   Web Tcl Complete    |      XML XSL
http://www.zveno.com/ |    TclXML TclDOM      | Tcl, Web Development

Ph. +61 2 6242 4099   | Mobile (0413) 594 462 | Fax +61 2 6242 4099



Fri, 14 Mar 2003 12:59:53 GMT  
 Tclxml question

Quote:
>> proc cdata {args} {
>>         global cdata
>>         set cdata $args
>> }

> Gotcha: the character data is always the first argument,
> so this should be 'set cdata [lindex $args 0]'.

Oh yeah. Well since it was written for a specific DTD, it was controlled.
The args was actually there for debugging.

L

--
MY EMAIL ADDRESS HAS CHANGED --> UPDATE YOUR ADDRESSBOOK

Laurent Duperval                 "Montreal winters are an intelligence test,
                                         and we who are here have failed it."

Penguin Power!         ***Nothing I say reflects the views of my employer***



Fri, 14 Mar 2003 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. tclxml package loading problems

2. ANNOUNCE: TclXML Version 3.1

3. TclXML/libxml2 Compilation Problems

4. Needed clarification on TCLXML and TCLdom

5. TclXML, where is the memory leak?

6. ANN: Version 3.0 of TclXML, TclDOM and TclXSLT

7. TclXML users? need a clue

8. ISO: help getting tclxml/tcldom 3.0b2 working

9. ANN: TclXML v3.0b2 Combo Binary for Mac OS X

10. ANN: Beta 2 of Version 3.0 of TclXML, TclDOM and TclXSLT

11. TclXML v3.0 Release Candidate 1

12. hints on installing tclxml w/o wish

 

 
Powered by phpBB® Forum Software