category_tree::xml::add_category (private)

 category_tree::xml::add_category -tree_id tree_id -parent_id parent_id \
    node

Defined in packages/categories/tcl/category-xml-procs.tcl

Imports one category.

Switches:
-tree_id (required)
-parent_id (required)
Parameters:
node (required)

Partial Call Graph (max 5 caller/called nodes):
%3 category_tree::xml::import category_tree::xml::import (public) category_tree::xml::add_category category_tree::xml::add_category category_tree::xml::import->category_tree::xml::add_category category::add category::add (public) category_tree::xml::add_category->category::add category::update category::update (public) category_tree::xml::add_category->category::update

Testcases:
No testcase defined.
Source code:
    set category_id 0
    
    # do translations
    foreach translation [$node selectNodes {translation}] {
        if {[catch {set locale [$translation getAttribute locale]}]} {
            error "Required attribute 'locale' not found"
        }
        if {[catch {set name [[$translation selectNodes {name}] text]}]} {
            error "Required element 'name' not found"
        }
        if {[catch {set description [[$translation selectNodes {description}] text]}]} {
            set description {}
        }

        if {$category_id} {
            # category exists, add translation
            category::update  -category_id $category_id  -locale $locale  -name $name  -description $description
        } else {
            # create category
            set category_id [category::add  -tree_id $tree_id  -parent_id $parent_id  -locale $locale  -name $name  -description $description]
        }
    }
    
    # do children
    foreach child [$node selectNodes {category}] {
        add_category -tree_id $tree_id -parent_id $category_id $child
    }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: