Forum OpenACS Q&A: New version of ns_xml breaks OpenACS 4

Collapse
Posted by Yon Derek on
Folks, due to a bugfix I've made to nsxml, OpenACS 4 no longer works because it relied on buggy behaviour.

The change: nsxml as lives in AOLServer's CVS on sourceforge has ns_xml doc root broken, it doesn't return a root element but a child of a root element. OpenACS relies on this buggy behaviour in db_qd_internal_parse_init. It requires one small fix:

    # Get the list of queries out
    set root_node [ns_xml doc root $parsed_doc]
Should be changed to:
    # Get the list of queries out
    set root_node [ns_xml doc root $parsed_doc]
 
    set root_node [ns_xml node children $root_node]

I believe that the right thing to do is to make this change and document that OpenACS requires ns_xml 1.4 or greater (available here: http://acs- misc.sourceforge.net/nsxml.html

I've tested the above fix. There might be other places in the code that rely on bug in old ns_xml.

Collapse
Posted by Neophytos Demetriou on
Thank you Derek. I was going to post about this problem.
Collapse
Posted by Neophytos Demetriou on
Yon, I have applied the fix but I still get an error. I have used earlier versions of nsxml succesfully with 3.2+ad12, libxml-2.3.5. Now I am using 3.3+ad13 and libxml2-2.3.14. The logs shows that the nsxml module loads succesfully. Here's the error I get:

Server startup failed: Error during bootstrapping

invalid node ID N0
    while executing
"ns_xml node children $root_node"
    (procedure "db_qd_internal_parse_init" line 12)
    invoked from within
"db_qd_internal_parse_init $whole_file $file_tag"
    (procedure "db_qd_internal_load_queries" line 15)
    invoked from within
"db_qd_internal_load_queries $stream $file_path"
    (procedure "db_qd_internal_load_cache" line 9)
    invoked from within
"db_qd_internal_load_cache $file_path"
    (procedure "db_qd_load_query_file" line 2)
    invoked from within
"db_qd_load_query_file $file"
    (procedure "apm_bootstrap_load_queries" line 26)
    invoked from within
"apm_bootstrap_load_queries acs-tcl"
Any suggestions?
Collapse
Posted by Yon Derek on
You have to upgrade to the latest version 1.4 which I have just releasesd at the url given above. It has the fix for this bug (that's why I said in the previous post that it should be documented that OpenACS 4 requires ns_xml 1.4 or above)
Collapse
Posted by Yon Derek on
BTW: use the CVS, I haven't updated the source tarball yet.
Collapse
Posted by Neophytos Demetriou on
Thank you Yon. I used CVS and it's working great.
Collapse
Posted by Neophytos Demetriou on
Relevant bug fix:
  • File: packages/acs-tcl/tcl/apm-xml-procs.tcl
  • Add this after line 296:
    set root_node [ns_xml node children $root_node]
    
Collapse
Posted by Don Baccus on
Is there any way we can check the version number easily, so it will still work with those who have 1.3?  We've got enough folks playing with OpenACS now that I can easily imagine the number of times we'll be told that the latest CVS tree of OpenACS is broken if we just blindly add the bug fix...
Collapse
Posted by Ben Adida on
Yon, thanks for this bug fix. I was extremely annoyed with this bug in
ns_xml when building the query dispatcher. Don is right: is there an
easy way for us to check the version? As soon as we have a clean way
to change this, I'll make the change in the QD.
Collapse
Posted by Yon Derek on
proc nsxml_broken_p { } {
  set doc '<?xml version="1.0"?><me>him</me>'
  set doc_id [ns_xml parse $doc]
  set root [ns_xml doc $doc_id]
  set name [ns_xml node name $root]
  if { [string_equal_p $name "me"] } {
    return 1
  }
  return 0
}
or something along those lines.
Collapse
Posted by Ben Adida on
This thread should have been on OpenACS4 forums, btw.

I have changed the XML parsing approach in OpenACS 4 to go
through a standard, simplified API (acs-tcl/tcl/30-xml-procs.tcl).
All XML parsing uses this API now, and the API checks ns_xml
compatibility and activates work-arounds if your version is
broken.

This code is moderately well tested, but could use more
pounding of course. If you're adventurous, update your CVS and
try reinstalling your OpenACS 4.x. Let me know how it works!