예제 #1
0
void GridComponent::save(const std::string &fullname)
{
	clan::DomDocument doc;

	clan::DomElement element_gui = doc.create_element("gui"); 
	element_gui.set_attribute("xmlns", "http://clanlib.org/xmlns/gui-1.0");
	
	doc.append_child(element_gui);

	clan::GUIComponent *comp = component_container->get_first_child();
	while (comp != 0)
	{
		if (comp->get_tag_name() == "object")
		{
			GridObject *object = dynamic_cast<GridObject*>(comp);
			if (object)
			{
				clan::DomElement element = object->to_element(doc);
				element_gui.append_child(element);
			}
		}
		
		comp = comp->get_next_sibling();
	}

	clan::DomElement element = to_element(doc); // save grid (window) settings
	element_gui.append_child(element);

	clan::File file;
	file.open(fullname, clan::File::create_always, clan::File::access_write);
	doc.save(file);
}
예제 #2
0
파일: test.cpp 프로젝트: nosid/lib-up
int main(int argc, char* argv[])
{
    try {

        std::ios::sync_with_stdio(false);

        auto origin = up::fs::origin(up::fs::context("root"));
        auto&& p = [origin,follow=false](up::shared_string pathname) {
            return up::fs::location(origin, std::move(pathname), follow);
        };
        for (int i = 1; i < argc; ++i) {
            std::cout << "FILE: " << argv[i] << '\n';
            using o = up::fs::file::option;
            auto document = up::xml::document(
                load(up::fs::file(p(argv[i]), {o::read})),
                {}, {}, up::xml::null_uri_loader(), {});
            dump(std::cout, document.to_element());
            std::cout << '\n';
            // auto stylesheet = up::xml::stylesheet(document);
            // document = stylesheet(document);
            // dump(std::cout, document.serialize()) << "\n\n";
        }

    } catch (...) {
        up::log_current_exception(std::cerr, "ERROR: ");
        return EXIT_FAILURE;
    }
}
예제 #3
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();
	}