本文整理汇总了C++中CL_DomNode::get_namespace_uri方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_DomNode::get_namespace_uri方法的具体用法?C++ CL_DomNode::get_namespace_uri怎么用?C++ CL_DomNode::get_namespace_uri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_DomNode
的用法示例。
在下文中一共展示了CL_DomNode::get_namespace_uri方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: named_item_ns
CL_DomNode CL_DomNode::named_item_ns(
const CL_DomString &namespace_uri,
const CL_DomString &local_name) const
{
CL_DomNode node = get_first_child();
while (node.is_null() == false)
{
if (node.get_namespace_uri() == namespace_uri && node.get_local_name() == local_name)
return node;
node = node.get_next_sibling();
}
return CL_DomNode();
}
示例2: create_resource
CL_Resource CL_ResourceManager::create_resource(const CL_String &resource_id, const CL_String &type)
{
if (resource_exists(resource_id))
throw CL_Exception(cl_format("Resource %1 already exists", resource_id));
std::vector<CL_String> path_elements = CL_PathHelp::split_basepath(resource_id);
CL_String name = CL_PathHelp::get_filename(resource_id);
// Walk tree as deep as we can get:
CL_DomNode parent = impl->document.get_document_element();
CL_DomNode cur = parent.get_first_child();
std::vector<CL_String>::iterator path_it = path_elements.begin();
while (!cur.is_null() && path_it != path_elements.end())
{
if (cur.is_element() &&
cur.get_namespace_uri() == impl->ns_resources &&
cur.get_local_name() == "section")
{
CL_DomElement element = cur.to_element();
CL_String name = element.get_attribute_ns(impl->ns_resources, "name");
if (name == *path_it)
{
++path_it;
parent = cur;
cur = cur.get_first_child();
continue;
}
}
cur = cur.get_next_sibling();
}
// Create any missing parent nodes:
CL_String prefix = parent.get_prefix();
while (path_it != path_elements.end())
{
CL_DomElement section;
if (prefix.empty())
{
section = impl->document.create_element_ns( impl->ns_resources, (*path_it) );
}
else
{
section = impl->document.create_element_ns( impl->ns_resources,(prefix + ":" + *path_it));
}
parent.append_child(section);
parent = section;
++path_it;
}
// Create node:
CL_DomElement resource_node;
if (prefix.empty())
{
resource_node = impl->document.create_element_ns( impl->ns_resources, (type));
}
else
{
resource_node = impl->document.create_element_ns( impl->ns_resources,(prefix + ":" + type));
}
resource_node.set_attribute_ns(
impl->ns_resources,
prefix.empty() ? "name" : (prefix + ":name"),
name);
parent.append_child(resource_node);
// Create resource:
impl->resources[resource_id] = CL_Resource(resource_node, *this);
return impl->resources[resource_id];
}
示例3: import_node
CL_DomNode CL_DomDocument::import_node(const CL_DomNode &node, bool deep)
{
CL_DomNode imported_node;
switch (node.get_node_type())
{
case NULL_NODE:
return imported_node;
case ELEMENT_NODE:
imported_node = create_element_ns(node.get_namespace_uri(), node.get_node_name());
break;
case ATTRIBUTE_NODE:
imported_node = create_attribute_ns(node.get_namespace_uri(), node.get_node_name());
imported_node.set_node_value(node.get_node_value());
break;
case TEXT_NODE:
imported_node = create_text_node(node.get_node_value());
break;
case CDATA_SECTION_NODE:
imported_node = create_cdata_section(node.get_node_value());
break;
case ENTITY_REFERENCE_NODE:
imported_node = create_entity_reference(node.get_node_name());
break;
case ENTITY_NODE:
return imported_node;
case PROCESSING_INSTRUCTION_NODE:
imported_node = create_processing_instruction(node.to_processing_instruction().get_target(), node.to_processing_instruction().get_data());
break;
case COMMENT_NODE:
imported_node = create_comment(node.get_node_value());
break;
case DOCUMENT_NODE:
imported_node = create_document_fragment();
break;
case DOCUMENT_TYPE_NODE:
return imported_node;
case DOCUMENT_FRAGMENT_NODE:
imported_node = create_document_fragment();
break;
case NOTATION_NODE:
return imported_node;
}
if (node.is_element())
{
CL_DomElement import_element = imported_node.to_element();
CL_DomNamedNodeMap node_attributes = node.get_attributes();
int size = node_attributes.get_length();
for (int index = 0; index < size; index++)
{
CL_DomNode attr = node_attributes.item(index);
import_element.set_attribute_node_ns(import_node(attr, deep).to_attr());
}
}
if (deep)
{
CL_DomNode cur = node.get_first_child();
while (!cur.is_null())
{
imported_node.append_child(import_node(cur, true));
cur = cur.get_next_sibling();
}
}
return imported_node;
}