Example #1
0
EPUB3_XML_BEGIN_NAMESPACE

Namespace::Namespace(Document * doc, const string &prefix, const string &uri)
{
    xmlDocPtr d = doc->xml();
    _xml = xmlNewNs(reinterpret_cast<xmlNodePtr>(d), uri.utf8(), prefix.utf8());
}
Example #2
0
EPUB3_XML_BEGIN_NAMESPACE

Namespace::Namespace(std::shared_ptr<Document> doc, const string &prefix, const string &uri)
{
    xmlDocPtr d = doc->xml();
    _xml = xmlNewNs(reinterpret_cast<xmlNodePtr>(d), uri.utf8(), prefix.utf8());
    if (_xml->_private != nullptr)
        Node::Unwrap((xmlNodePtr)_xml);
    
    _xml->_private = new LibXML2Private<Namespace>(this);
}
Example #3
0
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);
}
Example #4
0
xmlNodePtr Node::createChild(const string &name, const string &prefix) const
{
    xmlNs * ns = nullptr;
    if ( Type() != NodeType::Element )
        throw InternalError("Cannot add children to non-element node of type '" + TypeString(Type()) + "'");
    
    if ( prefix.empty() )
    {
        ns = xmlSearchNs(_xml->doc, _xml, nullptr);
    }
    else
    {
        // use the existing namespace if one exists
        ns = xmlSearchNs(_xml->doc, _xml, prefix.utf8());
        if ( ns == nullptr )
            throw InternalError(std::string("The namespace prefix '") + prefix.c_str() + "' is unknown");
    }
    
    return xmlNewNode(ns, name.utf8());
}
Example #5
0
void Node::SetBaseURL(const string &baseURL)
{
    xmlNodeSetBase(_xml, baseURL.utf8());
}
Example #6
0
void Node::SetLanguage(const string &language)
{
    xmlNodeSetLang(_xml, language.utf8());
}
Example #7
0
void Node::SetContent(const string &content)
{
    xmlNodeSetContent(_xml, content.utf8());
}
Example #8
0
void Node::SetName(const string &name)
{
    xmlNodeSetName(_xml, name.utf8());
}
Example #9
0
void Document::DeclareEntity(const string &name, EntityType type, const string &publicID, const string &systemID, const string &value)
{
	if (xmlAddDocEntity(xml(), name.utf8(), static_cast<int>(type), publicID.utf8(), systemID.utf8(), value.utf8()) == nullptr)
		throw InternalError(std::string("Unable to add entity declaration for ") + name.c_str());
}
Example #10
0
void Document::SetInternalSubset(const string &name, const string &externalID, const string &systemID)
{
	xmlDtd * dtd = xmlCreateIntSubset(xml(), name.utf8(), externalID.utf8(), systemID.utf8());
	if (dtd != nullptr && dtd->_private == nullptr)
		(void)Wrapped<DTD, _xmlDtd>(dtd);
}
Example #11
0
EPUB3_XML_BEGIN_NAMESPACE

#if EPUB_ENABLE(XML_BUILDER)
Document::Document(const string & version) : Node(reinterpret_cast<xmlNodePtr>(xmlNewDoc(version.utf8())))
{
}
Example #12
0
xmlEntityPtr Document::NamedEntity(const string &name) const
{
    return xmlGetDocEntity(const_cast<xmlDocPtr>(xml()), name.utf8());
}
Example #13
0
EPUB3_XML_BEGIN_NAMESPACE

Document::Document(const string & version) : Document(xmlNewDoc(version.utf8()))
{
}