Exemple #1
0
	DomString DomNode::get_node_value() const
	{
		if (impl)
		{
			const DomTreeNode *tree_node = impl->get_tree_node();
			switch (tree_node->node_type)
			{
			case DOCUMENT_NODE:
			case DOCUMENT_FRAGMENT_NODE:
			case DOCUMENT_TYPE_NODE:
			case ELEMENT_NODE:
			case ENTITY_NODE:
			case ENTITY_REFERENCE_NODE:
			case NOTATION_NODE:
				return DomString();

			case TEXT_NODE:
			case ATTRIBUTE_NODE:
			case PROCESSING_INSTRUCTION_NODE:
			default:
				return tree_node->get_node_value();
			}
		}
		return DomString();
	}
Exemple #2
0
	DomString DomElement::get_attribute_ns(
		const DomString &namespace_uri,
		const DomString &local_name) const
	{
		if (impl)
		{
			DomDocument_Impl *doc_impl = (DomDocument_Impl *)impl->owner_document.lock().get();
			const DomTreeNode *tree_node = impl->get_tree_node();
			unsigned int cur_index = tree_node->first_attribute;
			const DomTreeNode *cur_attribute = tree_node->get_first_attribute(doc_impl);
			while (cur_attribute)
			{
				std::string lname = cur_attribute->get_node_name();
				std::string::size_type lpos = lname.find_first_of(':');
				if (lpos != std::string::npos)
					lname = lname.substr(lpos + 1);

				if (cur_attribute->get_namespace_uri() == namespace_uri && lname == local_name)
					return cur_attribute->get_node_value();

				cur_index = cur_attribute->next_sibling;
				cur_attribute = cur_attribute->get_next_sibling(doc_impl);
			}
			return DomString();
		}
		return DomString();
	}
Exemple #3
0
	DomString DomNode::get_node_name() const
	{
		if (impl)
		{
			const DomTreeNode *tree_node = impl->get_tree_node();
			switch (tree_node->node_type)
			{
			case CDATA_SECTION_NODE:
				return "#cdata-section";
			case COMMENT_NODE:
				return "#comment";
			case DOCUMENT_NODE:
				return "#document";
			case DOCUMENT_FRAGMENT_NODE:
				return "#document-fragment";
			case TEXT_NODE:
				return "#text";
			case ATTRIBUTE_NODE:
			case DOCUMENT_TYPE_NODE:
			case ELEMENT_NODE:
			case ENTITY_NODE:
			case ENTITY_REFERENCE_NODE:
			case NOTATION_NODE:
			case PROCESSING_INSTRUCTION_NODE:
			default:
				return tree_node->get_node_name();
			}
		}
		return DomString();
	}
	DomString DomProcessingInstruction::get_data() const
	{
		if (impl)
			return impl->get_tree_node()->get_node_value();
		else
			return DomString();
	}
	DomString DomProcessingInstruction::get_target() const
	{
		if (impl)
			return impl->get_tree_node()->get_node_name();
		else
			return DomString();
	}
Exemple #6
0
	DomString DomNode::get_prefix() const
	{
		if (impl)
		{
			DomString node_name = impl->get_tree_node()->get_node_name();
			DomString::size_type pos = node_name.find(':');
			if (pos != DomString::npos)
				return node_name.substr(0, pos);
		}
		return DomString();
	}
Exemple #7
0
	DomString DomElement::get_attribute(const DomString &name) const
	{
		if (impl)
		{
			DomDocument_Impl *doc_impl = (DomDocument_Impl *)impl->owner_document.lock().get();
			const DomTreeNode *tree_node = impl->get_tree_node();
			unsigned int cur_index = tree_node->first_attribute;
			const DomTreeNode *cur_attribute = tree_node->get_first_attribute(doc_impl);
			while (cur_attribute)
			{
				if (cur_attribute->get_node_name() == name)
					return cur_attribute->get_node_value();

				cur_index = cur_attribute->next_sibling;
				cur_attribute = cur_attribute->get_next_sibling(doc_impl);
			}
			return DomString();
		}
		return DomString();
	}
Exemple #8
0
	DomString DomNode::get_local_name() const
	{
		if (impl)
		{
			DomString node_name = impl->get_tree_node()->get_node_name();
			DomString::size_type pos = node_name.find(':');
			if (pos != DomString::npos)
				return node_name.substr(pos + 1);
			else
				return node_name;
		}
		return DomString();
	}
Exemple #9
0
	DomString DomNode::find_namespace_uri(const DomString &qualified_name) const
	{
		static DomString xmlns_prefix("xmlns:");
		static DomString xmlns_xml("xml");
		static DomString xmlns_xml_uri("http://www.w3.org/XML/1998/namespace");
		static DomString xmlns_xmlns("xmlns");
		static DomString xmlns_xmlns_uri("http://www.w3.org/2000/xmlns/");

		DomString prefix;
		DomString::size_type pos = qualified_name.find(':');
		if (pos != DomString::npos)
			prefix = qualified_name.substr(0, pos);

		if (prefix == xmlns_xml)
			return xmlns_xml;
		else if (prefix == xmlns_xmlns || qualified_name == xmlns_xmlns)
			return xmlns_xmlns;

		DomDocument_Impl *doc_impl = (DomDocument_Impl *)impl->owner_document.lock().get();
		const DomTreeNode *cur = impl->get_tree_node();
		while (cur)
		{
			const DomTreeNode *cur_attr = cur->get_first_attribute(doc_impl);
			while (cur_attr)
			{
				std::string node_name = cur_attr->get_node_name();
				if (prefix.empty())
				{
					if (node_name == xmlns_xmlns)
						return cur_attr->get_node_value();
				}
				else
				{
					if (node_name.substr(0, 6) == xmlns_prefix && node_name.substr(6) == prefix)
						return cur_attr->get_node_value();
				}
				cur_attr = cur_attr->get_next_sibling(doc_impl);
			}
			cur = cur->get_parent(doc_impl);
		}
		return DomString();
	}
Exemple #10
0
	DomString DomNode::find_prefix(const DomString &namespace_uri) const
	{
		DomElement cur = to_element();
		while (!cur.is_null())
		{
			DomNamedNodeMap attributes = cur.get_attributes();
			int size = attributes.get_length();
			for (int index = 0; index < size; index++)
			{
				DomNode attribute = attributes.item(index);
				if (attribute.get_prefix() == "xmlns" &&
					attribute.get_node_value() == namespace_uri)
				{
					return attribute.get_local_name();
				}
			}
			cur = cur.get_parent_node().to_element();
		}
		return DomString();
	}
void DomCharacterData::delete_data(unsigned long offset, unsigned long count)
{
	if (impl)
	{
		DomString value = impl->get_tree_node()->get_node_value();
		if (offset > value.length())
			offset = value.length();
		if (offset + count > value.length())
			count = value.length() - offset;
		if (count == 0)
			return;

		if (count < value.length())
		{
			value = value.substr(0, offset) + value.substr(offset + count);
		}
		else
		{
			value = DomString();
		}
		impl->get_tree_node()->node_value = value;
	}
}
DomString DomCharacterData::substring_data(unsigned long offset, unsigned long count)
{
	if (impl)
		return get_node_value().substr(offset, count);
	return DomString();
}
Exemple #13
0
	DomString DomNode::get_namespace_uri() const
	{
		if (impl)
			return impl->get_tree_node()->get_namespace_uri();
		return DomString();
	}
Exemple #14
0
DomString DomEntity::get_notation_name() const
{
	return DomString();
}
Exemple #15
0
DomString DomEntity::get_system_id() const
{
	return DomString();
}
Exemple #16
0
DomString DomEntity::get_public_id() const
{
	return DomString();
}