Resource Property::asResource() const { if ( _type == NodeType::RESOURCE ) { return _factory->createIRIResource(_value); } else if ( _type == NodeType::BLANK ) { return _factory->createBlankNodeResource(_value); } else { throw InvalidNodeType("Unable to convert Property " + _iri + " as resource"); } }
Node::Node(const string & name, NodeType type, const string & content, const class Namespace & ns) { _xmlNode * newNode = nullptr; switch (type) { case NodeType::Element: // needs subclass break; case NodeType::Text: // needs subclass break; case NodeType::Attribute: // Not Applicable break; case NodeType::CDATASection: #ifdef LIBXML_DOCBOOK_ENABLED case NodeType::DocbookSGMLDocument: #endif case NodeType::Document: case NodeType::DocumentFragment: case NodeType::DTD: case NodeType::HTMLDocument: // need document ptr to create these break; case NodeType::Comment: // needs subclass break; case NodeType::ProcessingInstruction: newNode = xmlNewPI(name.utf8(), content.utf8()); break; default: newNode = xmlNewNode(const_cast<_xmlNs*>(ns.xml()), name.utf8()); break; } if ( newNode == nullptr ) throw InvalidNodeType(std::string("NodeType '") + TypeString(type) + "' is not supported"); _xml = newNode; _xml->_private = new LibXML2Private<Node>(this); }