Index: openacs-4/packages/acs-tcl/tcl/tdom-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/tdom-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-tcl/tcl/tdom-procs.tcl 30 Jul 2007 21:39:03 -0000 1.1 +++ openacs-4/packages/acs-tcl/tcl/tdom-procs.tcl 1 Aug 2007 08:30:53 -0000 1.2 @@ -5,12 +5,13 @@ Procedures to make parsing XML using TDOM a little easier + @author avni@ucla.edu (AK) @creation-date 2004/10/19 @cvs-id $Id$ - @tdom::get_node_pointer - @tdom::get_parent_node_pointer + @tdom::get_node_object + @tdom::get_parent_node_object @tdom::get_tag_value @tdom::get_attribute_value @tdom::get_node_xml @@ -19,12 +20,12 @@ namespace eval tdom {} -ad_proc -public tdom::get_node_pointer { - parent_node_pointer +ad_proc -public tdom::get_node_object { + parent_node_object args } { - Returns a pointer to the args given - If the pointer doesn't exist or the value is null, return null + Returns a tdom object to the args given + If the tdom object doesn't exist or the value is null, return null
Example ----------------------------------------------------- @@ -34,37 +35,37 @@ <last-name>Poe</last-name> </experimenter> </experiment> - Params: parent_node_pointer=$pointer_to_experiment + Params: parent_node_object=$tdom_experiment_object args=experimenter experimenter_two - Returns: Pointer to experimenter node + Returns: TDOM object for experimenter node End Example -------------------------------------------------} { # Do a loop for the args. The first non null result is returned - set node_pointer "" + set node_object "" foreach node_name $args { - catch {set node_pointer [$parent_node_pointer getElementsByTagName "$node_name"]} - if {![empty_string_p [string trim $node_pointer]]} { - return $node_pointer + catch {set node_object [$parent_node_object getElementsByTagName "$node_name"]} + if {![string equal $node_object ""]} { + return $node_object } } - return $node_pointer + return $node_object } -ad_proc -public tdom::get_parent_node_pointer { - child_node_pointer +ad_proc -public tdom::get_parent_node_object { + child_node_object } { - Returns a pointer to the parent node + Returns a tdom object for the parent node of the child node object passed in } { - set parent_node_pointer "" - catch {set parent_node_pointer [$child_node_pointer parentNode]} + set parent_node_object "" + catch {set parent_node_object [$child_node_object parentNode]} - return [string trim $parent_node_pointer] + return $parent_node_object } ad_proc -public tdom::get_tag_value { - node_pointer + node_object args } { Returns the tag value of the tag_name passed in @@ -73,7 +74,7 @@
Example ----------------------------------------------------- XML: <experiment-id>1222</experiment-id> - Params: node_pointer=$document + Params: node_object=$document args=experiment-id EXPERIMENT-ID Returns: 1222 End Example ------------------------------------------------- @@ -83,8 +84,8 @@ set tag_value "" foreach tag_name $args { - catch {set tag_value [[$node_pointer getElementsByTagName "$tag_name"] text]} errormsg - if {![empty_string_p [string trim $tag_value]]} { + catch {set tag_value [[$node_object getElementsByTagName "$tag_name"] text]} errormsg + if {![string equal [string trim $tag_value] ""]} { return $tag_value } } @@ -93,27 +94,26 @@ } ad_proc -public tdom::get_attribute_value { - node_pointer + node_object attribute_name {default_value ""} } { Returns the value of the attribute specified } { set attribute_value "" - catch {set attribute_value [$node_pointer getAttribute $attribute_name $default_value]} + catch {set attribute_value [$node_object getAttribute $attribute_name $default_value]} return [string trim $attribute_value] } ad_proc -public tdom::get_node_xml { - node_pointer + node_object } { - Returns xml of the data pointed to by the node pointer + Returns xml of the data pointed to by the node object If tag doesn't exist or the value is null, returns null } { set node_xml "" - catch {set node_xml [$node_pointer asXML]} + catch {set node_xml [$node_object asXML]} return [string trim $node_xml] -} - +} \ No newline at end of file