lang::catalog::parse (private)
lang::catalog::parse catalog_file_contents
Defined in packages/acs-lang/tcl/lang-catalog-procs.tcl
Parse the given catalog file xml contents and return the data as an array. The array will contain the following keys:
package_key locale charset messages - An array-list with message keys as keys and the message texts as values. descriptions - An array-list with message keys as keys and the descriptions as values.
- Parameters:
- catalog_file_contents (required)
- Authors:
- Peter Marklund <peter@collaboraid.biz>
- Simon Carstensen <simon@collaboraid.biz>
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- util__replace_temporary_tags_with_lookups
Source code: # Check arguments if { $catalog_file_contents eq "" } { error "lang::catalog::parse the catalog_file_contents arguments is the empty string" } # The names of xml tags and attributes set MESSAGE_CATALOG_TAG "message_catalog" set PACKAGE_KEY_ATTR "package_key" set LOCALE_ATTR "locale" set CHARSET_ATTR "charset" set MESSAGE_TAG "msg" set DESCRIPTION_TAG "description" set KEY_ATTR "key" # Initialize the array to return array set msg_catalog_array {} # Parse the XML document set tree [xml_parse -persist $catalog_file_contents] # Get the message catalog root node set root_node [xml_doc_get_first_node $tree] if { [xml_node_get_name $root_node] ne $MESSAGE_CATALOG_TAG } { $tree delete error "lang::catalog_parse: Could not find root node $MESSAGE_CATALOG_TAG" } # Set the message catalog root level attributes set msg_catalog_array(package_key) [get_required_xml_attribute $root_node ${PACKAGE_KEY_ATTR}] set msg_catalog_array(locale) [get_required_xml_attribute $root_node ${LOCALE_ATTR}] set msg_catalog_array(charset) [get_required_xml_attribute $root_node ${CHARSET_ATTR}] # Loop over the keys and message texts set message_node_list [xml_node_get_children_by_name $root_node ${MESSAGE_TAG}] array set key_text_array {} foreach message_node $message_node_list { set key [get_required_xml_attribute $message_node ${KEY_ATTR}] set text [xml_node_get_content $message_node ] set key_text_array($key) $text } # Add the keys and the texts to the messages array set msg_catalog_array(messages) [array get key_text_array] # Loop over the keys and descriptions set description_node_list [xml_node_get_children_by_name $root_node ${DESCRIPTION_TAG}] array set key_description_array {} foreach description_node $description_node_list { set key [get_required_xml_attribute $description_node ${KEY_ATTR}] set description [xml_node_get_content $description_node ] set key_description_array($key) $description } # Add the keys and the texts to the descriptions array set msg_catalog_array(descriptions) [array get key_description_array] $tree delete return [array get msg_catalog_array]Generic XQL file: packages/acs-lang/tcl/lang-catalog-procs.xql
PostgreSQL XQL file: packages/acs-lang/tcl/lang-catalog-procs-postgresql.xql
Oracle XQL file: packages/acs-lang/tcl/lang-catalog-procs-oracle.xql