Index: openacs-4/packages/acs-tcl/tcl/30-xml-utils-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/30-xml-utils-procs.tcl,v diff -u -r1.4.4.1 -r1.4.4.2 --- openacs-4/packages/acs-tcl/tcl/30-xml-utils-procs.tcl 26 Feb 2003 02:25:00 -0000 1.4.4.1 +++ openacs-4/packages/acs-tcl/tcl/30-xml-utils-procs.tcl 26 Feb 2003 21:59:28 -0000 1.4.4.2 @@ -25,14 +25,18 @@ set ok_p 0 } else { if {![_nsxml_comments_ok_p]} { - append xml_status_msg "Your ns_xml doesn't support XML comments correctly. This issue is currently handled smoothly by some internal work-arounds, but you might want to upgrade ns_xml to the latest version ASAP.

" + append xml_status_msg "Your ns_xml doesn't support XML comments correctly. This issue is currently handled smoothly by some internal work-arounds, but you might want to upgrade ns_xml to the latest version.

" set ok_p 0 } if {![_nsxml_root_node_ok_p]} { - append xml_status_msg "Your ns_xml doesn't correctly return the root XML node. This issue is currently handled smoothly by some internal work-arounds, but you might want to upgrade ns_xml to the latest version ASAP.

" + append xml_status_msg "Your ns_xml doesn't correctly return the root XML node. This issue is currently handled smoothly by some internal work-arounds, but you might want to upgrade ns_xml to the latest version.

" set ok_p 0 } + + if {![_nsxml_version_2_p]} { + append xml_status_msg "Your ns_xml doesn't support the most recent command syntax. This issue is currently handled smoothly by some internal work-arounds, but you might want to upgrade ns_xml to the latest version.

" + } } return $ok_p @@ -145,12 +149,21 @@ # Get Node Attribute proc xml_node_get_attribute {node_id attribute_name} { - return [ns_xml node get attr $node_id $attribute_name] + + if { [_nsxml_version_2_p] } { + return [ns_xml node get attr $node_id $attribute_name] + } else { + return [ns_xml node getattr $node_id $attribute_name] + } } # Get Content proc xml_node_get_content {node_id} { - return [ns_xml node get content $node_id] + if { [_nsxml_version_2_p] } { + return [ns_xml node get content $node_id] + } else { + return [ns_xml node getcontent $node_id] + } } ## @@ -191,7 +204,6 @@ return $result } - # Check if comments are okay proc _nsxml_comments_ok_p {} { @@ -221,3 +233,28 @@ nsv_set NSXML comments_ok_p $result return $result } + +# Check if comments are okay +proc _nsxml_version_2_p {} { + + # Check cache + if {[nsv_exists NSXML version_2_p]} { + return [nsv_get NSXML version_2_p] + } + + # try to parse a sample XML document with content + set sample_xml "text" + set doc_id [ns_xml parse $sample_xml] + + if { [catch {ns_xml node get attr $doc_id root} errmsg] && + [string equal $errmsg "unknown command"] } { + set result 0 + } else { + set result 1 + } + + # store in cache and return + nsv_set NSXML version_2_p $result + return $result +} + Index: openacs-4/packages/acs-tcl/tcl/apm-xml-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-xml-procs.tcl,v diff -u -r1.11.2.1 -r1.11.2.2 --- openacs-4/packages/acs-tcl/tcl/apm-xml-procs.tcl 26 Feb 2003 02:25:00 -0000 1.11.2.1 +++ openacs-4/packages/acs-tcl/tcl/apm-xml-procs.tcl 26 Feb 2003 21:59:28 -0000 1.11.2.2 @@ -17,7 +17,7 @@ } { set value [apm_attribute_value $element $attribute] if { [empty_string_p $value] } { - error "Required attribute \"$attribute\" missing from <[ns_xml node get name $element]>" + error "Required attribute \"$attribute\" missing from <[xml_node_get_name $element]>" } return $value } @@ -31,7 +31,7 @@ Parses the XML element to return the value for the specified attribute. } { - set value [ns_xml node get attr $element $attribute] + set value [xml_node_get_attribute $element $attribute] if { [empty_string_p $value] } { return $default @@ -51,13 +51,13 @@ set node [lindex [xml_node_get_children_by_name $root $property_name] 0] if { ![empty_string_p $node] } { - set child [lindex [ns_xml node children $node] 0] + set child [lindex [xml_node_get_children $node] 0] # JCD 20020914 ns_xml when given something like (i.e. empty content) # will have the node but the node will not have a child node and the # getcontent will then fail. if { ![empty_string_p $child] } { - return [ns_xml node get content $child] + return [xml_node_get_content $child] } } return $default @@ -273,7 +273,7 @@ set tree [xml_parse $xml_data] set root_node [xml_doc_get_first_node_by_name $tree package] - apm_log APMDebug "XML: root node is [ns_xml node name $root_node]" + apm_log APMDebug "XML: root node is [xml_node_get_name $root_node]" set package $root_node set root_name [xml_node_get_name $package]