Forum OpenACS Q&A: variables to xml and back

Collapse
Posted by Benjamin Brink on
Hi,

Are there any benefits to using "the" OpenACS way to handle xml transactions via tdom::* procs in acs-tcl package?

Is there any documentation (besides the hint in api-doc) and examples anywhere?

I see some evidence of tdom being used directly. For example, acs-api-browser has one case of using "dom parse". acs-tcl packages appears to have numerous cases of using tdom in the tcl/*xml*-*procs.tcl files, but no public api doc.

cheers,
Ben

Collapse
Posted by Benjamin Brink on
Looks like the tdom:: procs are the way forward; and may be used to create other ways.

I need to learn tcl object conventions. And run some example tests, then will probably have some more specific questions.

Thank you.

Collapse
Posted by Benjamin Brink on
LOL. I may have figured out a way of representing DOM in tcl that fits non-OO semantics. I've already used the technique without realizing its potential for XML. Might be a little slower by the operation, but heck of a lot easier (for me) to visualize and use. Will explain with some examples after some sleep etc.

Basically: xml_obj_larr([list $node1 $node2 $node3 .. $nodeN]) [list $element1 $element2 ..]

In code I write '_larr' is array suffix short for list array ie. an array where each value is a list. In XDCPM, I put paths ie nodes in the hash to shortcut some network analysis..

goodnight,
Ben

Collapse
Posted by Benjamin Brink on

Oops. Messed up the terminology.

Looks like there needs to be two arrays:

For a node N elements deep, M repetitions, P attributes:

set hash [list $element1 $element2 .. $elementN]

text is in a list:

set dom_obj_text_larr(${hash}) [list text1 text2 text3 .. textM]

Attribute value pairs is in same element hash, different array. Value is a standard name/value list:

set dom_obj_att_val_larr(${hash}) [list $attribute1 $value1 .. $attributeP $valueP]

Still exploring..

Collapse
Posted by Benjamin Brink on

Attribute value pairs of $dom_obj_att_val_larr($hash) needs to be restated in context of the other array's values, since each element may have different att/value pairs, with or without text.

set dom_obj_att_val_larr(${hash}) [list \
[list $attribute1 $value1 .. $attributeP $valueP] \ < --for case text1
[list $attribute1 $value1 .. $attributeP $valueP] \ < --for case text2
...
[list $attribute1 $value1 .. $attributeP $valueP] \ < --for case textM

The default value for $dom_obj_text_larr(${hash}) elements without text is an empty list.

Collapse
Posted by Benjamin Brink on
This likely isn't appropriate for dynamic xml DOMs, but seems straightforward for importing/exporting static cases.