• Publicity: Public Only All

30-xml-utils-procs.tcl

This set of utilities was created back in the days when ns_xml was the preferred AOLserver XML api. It came in handy to have such an abstraction when the project switched to the tDOM library, so it stayed around, even if now is composed mostly by trivial one-liners. It is not clear whether it would make more sense to use tDOM directly and avoid this extra layer altogether in the future. Notable places where this library is in use are the APM and xml-rpc package (which also provides some automated tests for it).

Location:
packages/acs-tcl/tcl/30-xml-utils-procs.tcl

Procedures in this file

Detailed information

xml_doc_free (public)

 xml_doc_free doc_id

Free the doc

Parameters:
doc_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_xml_rpc_fault xml_rpc_fault (test xml-rpc) xml_doc_free xml_doc_free test_xml_rpc_fault->xml_doc_free test_xml_rpc_respond xml_rpc_respond (test xml-rpc) test_xml_rpc_respond->xml_doc_free apm_read_package_info_file apm_read_package_info_file (public) apm_read_package_info_file->xml_doc_free db_qd_internal_parse_one_query db_qd_internal_parse_one_query (private) db_qd_internal_parse_one_query->xml_doc_free xmlrpc::fault xmlrpc::fault (private) xmlrpc::fault->xml_doc_free xmlrpc::invoke xmlrpc::invoke (private) xmlrpc::invoke->xml_doc_free xmlrpc::parse_response xmlrpc::parse_response (private) xmlrpc::parse_response->xml_doc_free

Testcases:
xml_rpc_fault, xml_rpc_respond

xml_doc_get_first_node (public)

 xml_doc_get_first_node doc_id

Get first node

Parameters:
doc_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_xml_get_child_node_content_by_path xml_get_child_node_content_by_path (test acs-tcl) xml_doc_get_first_node xml_doc_get_first_node test_xml_get_child_node_content_by_path->xml_doc_get_first_node test_xml_rpc_fault xml_rpc_fault (test xml-rpc) test_xml_rpc_fault->xml_doc_get_first_node test_xml_rpc_respond xml_rpc_respond (test xml-rpc) test_xml_rpc_respond->xml_doc_get_first_node aa_test::parse_install_file aa_test::parse_install_file (public) aa_test::parse_install_file->xml_doc_get_first_node aa_test::parse_test_file aa_test::parse_test_file (public) aa_test::parse_test_file->xml_doc_get_first_node apm_get_package_repository apm_get_package_repository (public) apm_get_package_repository->xml_doc_get_first_node apm_load_install_xml apm_load_install_xml (private) apm_load_install_xml->xml_doc_get_first_node apm_load_install_xml_file apm_load_install_xml_file (private) apm_load_install_xml_file->xml_doc_get_first_node

Testcases:
xml_get_child_node_content_by_path, xml_rpc_fault, xml_rpc_respond

xml_doc_render (public)

 xml_doc_render doc_id [ indent_p ]

Render the doc

Parameters:
doc_id (required)
indent_p (optional, defaults to "f")
Returns:
XML

Partial Call Graph (max 5 caller/called nodes):
%3 xmlrpc::fault xmlrpc::fault (private) xml_doc_render xml_doc_render xmlrpc::fault->xml_doc_render xmlrpc::remote_call xmlrpc::remote_call (public) xmlrpc::remote_call->xml_doc_render xmlrpc::respond xmlrpc::respond (private) xmlrpc::respond->xml_doc_render

Testcases:
No testcase defined.

xml_node_get_attribute (public)

 xml_node_get_attribute node_id attribute_name [ default ]

Get Node Attribute

Parameters:
node_id (required)
attribute_name (required)
default (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 aa_test::parse_install_file aa_test::parse_install_file (public) xml_node_get_attribute xml_node_get_attribute aa_test::parse_install_file->xml_node_get_attribute aa_test::parse_test_file aa_test::parse_test_file (public) aa_test::parse_test_file->xml_node_get_attribute apm_attribute_value apm_attribute_value (public) apm_attribute_value->xml_node_get_attribute apm_get_package_repository apm_get_package_repository (public) apm_get_package_repository->xml_node_get_attribute auth::sync::process_doc::ims::ProcessDocument auth::sync::process_doc::ims::ProcessDocument (private) auth::sync::process_doc::ims::ProcessDocument->xml_node_get_attribute

Testcases:
No testcase defined.

xml_node_get_children (public)

 xml_node_get_children parent_node

Get children nodes

Parameters:
parent_node (required)

Partial Call Graph (max 5 caller/called nodes):
%3 aa_test::parse_install_file aa_test::parse_install_file (public) xml_node_get_children xml_node_get_children aa_test::parse_install_file->xml_node_get_children apm::process_install_xml apm::process_install_xml (public) apm::process_install_xml->xml_node_get_children apm_read_package_info_file apm_read_package_info_file (public) apm_read_package_info_file->xml_node_get_children install::xml::action::add-subsite-admin install::xml::action::add-subsite-admin (public) install::xml::action::add-subsite-admin->xml_node_get_children install::xml::action::add-subsite-member install::xml::action::add-subsite-member (public) install::xml::action::add-subsite-member->xml_node_get_children

Testcases:
No testcase defined.

xml_node_get_children_by_name (public)

 xml_node_get_children_by_name parent_node name

Find nodes of a parent that have a given name

Parameters:
parent_node (required)
name (required)

Partial Call Graph (max 5 caller/called nodes):
%3 aa_test::parse_test_file aa_test::parse_test_file (public) xml_node_get_children_by_name xml_node_get_children_by_name aa_test::parse_test_file->xml_node_get_children_by_name apm::process_install_xml apm::process_install_xml (public) apm::process_install_xml->xml_node_get_children_by_name apm_get_package_repository apm_get_package_repository (public) apm_get_package_repository->xml_node_get_children_by_name apm_read_package_info_file apm_read_package_info_file (public) apm_read_package_info_file->xml_node_get_children_by_name auth::sync::process_doc::ims::ProcessDocument auth::sync::process_doc::ims::ProcessDocument (private) auth::sync::process_doc::ims::ProcessDocument->xml_node_get_children_by_name

Testcases:
No testcase defined.

xml_node_get_children_by_select (public)

 xml_node_get_children_by_select parent_node xpath

Get children of given node that match supplied XPATH query

Parameters:
parent_node (required)
xpath (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

xml_node_get_content (public)

 xml_node_get_content node_id

Get Content

Parameters:
node_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 aa_test::parse_install_file aa_test::parse_install_file (public) xml_node_get_content xml_node_get_content aa_test::parse_install_file->xml_node_get_content aa_test::parse_test_file aa_test::parse_test_file (public) aa_test::parse_test_file->xml_node_get_content apm::package_version::attributes::parse_xml apm::package_version::attributes::parse_xml (private) apm::package_version::attributes::parse_xml->xml_node_get_content apm_get_package_repository apm_get_package_repository (public) apm_get_package_repository->xml_node_get_content apm_read_package_info_file apm_read_package_info_file (public) apm_read_package_info_file->xml_node_get_content

Testcases:
No testcase defined.

xml_node_get_first_child (public)

 xml_node_get_first_child parent_node

Returns the first child node

Parameters:
parent_node (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_xml_rpc_fault xml_rpc_fault (test xml-rpc) xml_node_get_first_child xml_node_get_first_child test_xml_rpc_fault->xml_node_get_first_child test_xml_rpc_respond xml_rpc_respond (test xml-rpc) test_xml_rpc_respond->xml_node_get_first_child xmlrpc::decode_value xmlrpc::decode_value (private) xmlrpc::decode_value->xml_node_get_first_child xmlrpc::invoke xmlrpc::invoke (private) xmlrpc::invoke->xml_node_get_first_child xmlrpc::parse_response xmlrpc::parse_response (private) xmlrpc::parse_response->xml_node_get_first_child

Testcases:
xml_rpc_fault, xml_rpc_respond

xml_node_get_first_child_by_name (public)

 xml_node_get_first_child_by_name parent_node name

Returns the first child node that has a given name

Parameters:
parent_node (required)
name (required)

Partial Call Graph (max 5 caller/called nodes):
%3 apm::package_version::attributes::parse_xml apm::package_version::attributes::parse_xml (private) xml_node_get_first_child_by_name xml_node_get_first_child_by_name apm::package_version::attributes::parse_xml->xml_node_get_first_child_by_name apm_get_package_repository apm_get_package_repository (public) apm_get_package_repository->xml_node_get_first_child_by_name apm_read_package_info_file apm_read_package_info_file (public) apm_read_package_info_file->xml_node_get_first_child_by_name apm_tag_value apm_tag_value (private) apm_tag_value->xml_node_get_first_child_by_name db_qd_internal_parse_one_query_from_xml_node db_qd_internal_parse_one_query_from_xml_node (private) db_qd_internal_parse_one_query_from_xml_node->xml_node_get_first_child_by_name

Testcases:
No testcase defined.

xml_node_get_name (public)

 xml_node_get_name node_id

Get Node Name

Parameters:
node_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 apm_invoke_install_proc apm_invoke_install_proc (public) xml_node_get_name xml_node_get_name apm_invoke_install_proc->xml_node_get_name apm_read_package_info_file apm_read_package_info_file (public) apm_read_package_info_file->xml_node_get_name apm_required_attribute_value apm_required_attribute_value (public) apm_required_attribute_value->xml_node_get_name auth::sync::process_doc::ims::GetAcknowledgementDocument auth::sync::process_doc::ims::GetAcknowledgementDocument (private) auth::sync::process_doc::ims::GetAcknowledgementDocument->xml_node_get_name auth::sync::process_doc::ims::ProcessDocument auth::sync::process_doc::ims::ProcessDocument (private) auth::sync::process_doc::ims::ProcessDocument->xml_node_get_name

Testcases:
No testcase defined.

xml_node_get_type (public)

 xml_node_get_type node_id

Get Node Type

Parameters:
node_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

xml_node_set_attribute (public)

 xml_node_set_attribute node_id attribute_name value

Set Node Attribute

Parameters:
node_id (required)
attribute_name (required)
value (required)

Partial Call Graph (max 5 caller/called nodes):
%3 install::xml::action::location install::xml::action::location (public) xml_node_set_attribute xml_node_set_attribute install::xml::action::location->xml_node_set_attribute install::xml::action::wizard install::xml::action::wizard (public) install::xml::action::wizard->xml_node_set_attribute

Testcases:
No testcase defined.

xml_parse (public)

 xml_parse [ -persist ] xml

Parse a document and return a doc_id

Switches:
-persist (optional, boolean)
decides whether returned document object will be deleted when the connection is closed or will be kept in server memory
Parameters:
xml (required)
Returns:
parsed document object handle

Partial Call Graph (max 5 caller/called nodes):
%3 test_files__check_xql_files files__check_xql_files (test acs-tcl) xml_parse xml_parse test_files__check_xql_files->xml_parse test_xml_get_child_node_content_by_path xml_get_child_node_content_by_path (test acs-tcl) test_xml_get_child_node_content_by_path->xml_parse test_xml_rpc_decode_value xml_rpc_decode_value (test xml-rpc) test_xml_rpc_decode_value->xml_parse test_xml_rpc_fault xml_rpc_fault (test xml-rpc) test_xml_rpc_fault->xml_parse test_xml_rpc_respond xml_rpc_respond (test xml-rpc) test_xml_rpc_respond->xml_parse dom dom xml_parse->dom aa_test::parse_install_file aa_test::parse_install_file (public) aa_test::parse_install_file->xml_parse aa_test::parse_test_file aa_test::parse_test_file (public) aa_test::parse_test_file->xml_parse apm_get_package_repository apm_get_package_repository (public) apm_get_package_repository->xml_parse apm_load_install_xml apm_load_install_xml (private) apm_load_install_xml->xml_parse apm_load_install_xml_file apm_load_install_xml_file (private) apm_load_install_xml_file->xml_parse

Testcases:
xml_get_child_node_content_by_path, files__check_xql_files, xml_rpc_fault, xml_rpc_decode_value, xml_rpc_respond

xml_support_ok (public)

 xml_support_ok varname

The proc that checks that XML support is complete

Parameters:
varname (required)
Returns:
boolean

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.
[ hide source ] | [ make this the default ]

Content File Source

ad_library {
    This set of utilities was created back in the days when ns_xml was
    the preferred AOLserver XML api. It came in handy to have such an
    abstraction when the project switched to the tDOM library, so it
    stayed around, even if now is composed mostly by trivial
    one-liners.

    It is not clear whether it would make more sense to use tDOM
    directly and avoid this extra layer altogether in the future.
    Notable places where this library is in use are the APM and
    xml-rpc package (which also provides some automated tests for it).
}

ad_proc -public xml_support_ok {varname} {
    The proc that checks that XML support is complete

    @arg varname a variable name in the caller namespace where the
         eventual error message will be reported

    @return boolean
} {
    upvar $varname xml_status_msg

    set ok_p 1

    if {[namespace which ::tdom] eq ""} {
        set xml_status_msg "tDOM is not installed! You must have tDOM installed, or nothing will work."
        set ok_p 0
    }

    return $ok_p
}

d_proc -public xml_parse {
    -persist:boolean
    xml
} {
    Parse a document and return a doc_id

    @param persist decides whether returned document object will be
    deleted when the connection is closed or will be kept in server
    memory

    @arg xml XML document

    @return parsed document object handle
} {
    if {$persist_p} {
        return [dom parse -simple -- $xml]
    } else {
        dom parse -simple -- $xml doc
        return $doc
    }
}

ad_proc -public xml_doc_free {doc_id} {
    Free the doc
} {
#   ns_log notice "xml_doc_free $doc_id"
    $doc_id delete
}

ad_proc xml_doc_get_first_node {doc_id} {
    Get first node
} {
#   ns_log notice "xml_doc_get_first_node $doc_id --> [[$doc_id documentElement] nodeName]"
    return [$doc_id documentElement]
}

ad_proc -public xml_node_get_children {parent_node} {
    Get children nodes
} {
    return [$parent_node child all]
}

d_proc -public xml_node_get_children_by_name {
    parent_node
    name
} {
    Find nodes of a parent that have a given name
} {
#   set msg "xml_node_get_children_by_name [$parent_node nodeName] $name --> "
#   foreach child [$parent_node child all $name] {
#    append msg "[$child nodeName] "
#   }
#   ns_log notice $msg
    return [$parent_node child all $name]
}

ad_proc -public xml_node_get_first_child {parent_node} {
    Returns the first child node
} {
#   ns_log notice "xml_node_get_first_child [$parent_node nodeName] --> [[$parent_node child 1] nodeName]"
    return [$parent_node child 1]
}

d_proc -public xml_node_get_first_child_by_name {
    parent_node
    name
} {
    Returns the first child node that has a given name
} {
#   ns_log notice "xml_node_get_first_child_by_name [$parent_node nodeName] $name --> [[$parent_node child 1 $name] nodeName]"
    return [$parent_node child 1 $name]
}

ad_proc -public xml_node_get_name {node_id} {
    Get Node Name
} {
    return [$node_id nodeName]
}

d_proc -public xml_node_get_attribute {
    node_id
    attribute_name
    {default ""}
} {
    Get Node Attribute
} {
#   ns_log notice "xml_node_get_attribute [$node_id nodeName] $attribute_name --> [$node_id getAttribute $attribute_name $default]"
    return [$node_id getAttribute $attribute_name $default]
}

d_proc -public xml_node_set_attribute {
    node_id
    attribute_name
    value
} {
    Set Node Attribute
} {
    $node_id setAttribute $attribute_name $value
}

ad_proc -public xml_node_get_content {node_id} {
    Get Content
} {
#   ns_log notice "xml_node_get_content [$node_id nodeName] --> [$node_id text]"
    return [$node_id text]
}

ad_proc -public xml_node_get_type {node_id} {
    Get Node Type
} {
    return [$node_id nodeType]
}

d_proc -public xml_doc_render {
    doc_id
    {indent_p f}
} {
    Render the doc

    @arg indent_p decides whether results should be indented or not

    @return XML
} {
    if { [string is true $indent_p] } {
        return [$doc_id asXML]
    } else {
        return [$doc_id asXML -indent none]
    }
}

d_proc -public xml_node_get_children_by_select {
    parent_node
    xpath
} {
    Get children of given node that match supplied XPATH query
} {
    return [$parent_node selectNodes $xpath]
}

# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: