void DOMBuilder::characters(const XMLChar ch[], int start, int length) { if (_inCDATA) { if (_pPrevious && _pPrevious->nodeType() == Node::CDATA_SECTION_NODE) { static_cast<CDATASection*>(_pPrevious)->appendData(XMLString(ch + start, length)); } else { AutoPtr<CDATASection> pCDATA = _pDocument->createCDATASection(XMLString(ch + start, length)); appendNode(pCDATA); } } else { if (_pPrevious && _pPrevious->nodeType() == Node::TEXT_NODE) { static_cast<Text*>(_pPrevious)->appendData(XMLString(ch + start, length)); } else { AutoPtr<Text> pText = _pDocument->createTextNode(XMLString(ch + start, length)); appendNode(pText); } } }
void ParserEngine::handleStartDoctypeDecl(void* userData, const XML_Char* doctypeName, const XML_Char *systemId, const XML_Char* publicId, int hasInternalSubset) { ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData); if (pThis->_pLexicalHandler) { XMLString sysId = systemId ? XMLString(systemId) : EMPTY_STRING; XMLString pubId = publicId ? XMLString(publicId) : EMPTY_STRING; pThis->_pLexicalHandler->startDTD(doctypeName, pubId, sysId); } }
void CSAX2ParserBase::HandleNotationDecl(const XML_Char* notationName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId) { csl_assert (notationName != NULL); XMLString pId; if (publicId) pId = XMLString(publicId); XMLString sId; if (systemId) sId = XMLString(systemId); if (m_pDTDHandler) m_pDTDHandler->NotationDecl(notationName, publicId ? &pId : NULL, systemId ? &sId : NULL); }
void explorer_show_frame(int cmdShow, LPTSTR lpCmdLine) { ExplorerCmd cmd; if (g_Globals._hMainWnd) { if (IsIconic(g_Globals._hMainWnd)) ShowWindow(g_Globals._hMainWnd, SW_RESTORE); else SetForegroundWindow(g_Globals._hMainWnd); return; } g_Globals._prescan_nodes = false; XMLPos explorer_options = g_Globals.get_cfg("general/explorer"); XS_String mdiStr = XMLString(explorer_options, "mdi"); // If there isn't yet the "mdi" setting in the configuration, display the MDI/SDI dialog. if (mdiStr.empty()) Dialog::DoModal(IDD_MDI_SDI, WINDOW_CREATOR(MdiSdiDlg), g_Globals._hwndDesktop); // Now read the MDI attribute again and interpret it as boolean value. cmd._mdi = XMLBool(explorer_options, "mdi", true); cmd._cmdShow = cmdShow; // parse command line options, which may overwrite the MDI flag if (lpCmdLine) cmd.ParseCmdLine(lpCmdLine); // create main window MainFrameBase::Create(cmd); }
void ParserEngine::handleStartNamespaceDecl(void* userData, const XML_Char* prefix, const XML_Char* uri) { ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData); if (pThis->_pContentHandler) pThis->_pContentHandler->startPrefixMapping((prefix ? XMLString(prefix) : EMPTY_STRING), (uri ? XMLString(uri) : EMPTY_STRING)); }
void ParserEngine::handleEndNamespaceDecl(void* userData, const XML_Char* prefix) { ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData); if (pThis->_pContentHandler) pThis->_pContentHandler->endPrefixMapping(prefix ? XMLString(prefix) : EMPTY_STRING); }
XMLString CAttributeListImp::GetValue(const XMLString& name) const { Attrib* pAttr = Find(name); if (pAttr) return pAttr->m_value; else return XMLString(); }
XMLString Name::prefix(const XMLString& qname) { XMLString::size_type pos = qname.find(':'); if (pos != XMLString::npos) return XMLString(qname, 0, pos); else return EMPTY_NAME; }
XMLString Name::localName(const XMLString& qname) { XMLString::size_type pos = qname.find(':'); if (pos != XMLString::npos) return XMLString(qname, pos + 1, qname.size() - pos - 1); else return qname; }
void translateDOMRangeException(const xercesc::DOMRangeException& e) { assert(pyXercesDOMExceptionType != nullptr); boost::python::object instance(e); boost::python::object exceptionType(boost::python::handle<>(boost::python::borrowed(pyXercesDOMExceptionType))); exceptionType.attr("cause") = instance; PyErr_SetString(pyXercesDOMExceptionType, XMLString(e.getMessage()).toString().c_str()); }
void CSAX2ParserBase::HandleUnparsedEntityDecl(const XML_Char* entityName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId, const XML_Char* notationName) { csl_assert (entityName != NULL && systemId != NULL && notationName != NULL); XMLString pId; if (publicId) pId = XMLString(publicId); if (m_pDTDHandler) m_pDTDHandler->UnparsedEntityDecl(entityName, publicId ? &pId : NULL, systemId, notationName); }
void Container::LoadEncryption() { unique_ptr<ArchiveReader> pZipReader = _archive->ReaderAtPath(gEncryptionFilePath); if ( !pZipReader ) return; ArchiveXmlReader reader(std::move(pZipReader)); #if EPUB_USE(LIBXML2) shared_ptr<xml::Document> enc = reader.xmlReadDocument(gEncryptionFilePath, nullptr, XML_PARSE_RECOVER|XML_PARSE_NOENT|XML_PARSE_DTDATTR); #elif EPUB_USE(WIN_XML) auto enc = reader.ReadDocument(gEncryptionFilePath, nullptr, 0); #endif if ( !bool(enc) ) return; #if EPUB_COMPILER_SUPPORTS(CXX_INITIALIZER_LISTS) XPathWrangler xpath(enc, {{"enc", XMLENCNamespaceURI}, {"ocf", OCFNamespaceURI}}); #else XPathWrangler::NamespaceList __ns; __ns["ocf"] = OCFNamespaceURI; __ns["enc"] = XMLENCNamespaceURI; XPathWrangler xpath(enc, __ns); #endif xml::NodeSet nodes = xpath.Nodes("/ocf:encryption/enc:EncryptedData"); if ( nodes.empty() ) { xml::string str(enc->XMLString()); printf("%s\n", enc->XMLString().utf8()); return; // should be a hard error? } for ( auto node : nodes ) { auto encPtr = EncryptionInfo::New(Ptr()); if ( encPtr->ParseXML(node) ) _encryption.push_back(encPtr); } }
void XMLWriter::dataElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& data, const XMLString& attr1, const XMLString& value1, const XMLString& attr2, const XMLString& value2, const XMLString& attr3, const XMLString& value3) { AttributesImpl attributes; if (!attr1.empty()) attributes.addAttribute(XMLString(), XMLString(), attr1, CDATA, value1); if (!attr2.empty()) attributes.addAttribute(XMLString(), XMLString(), attr2, CDATA, value2); if (!attr3.empty()) attributes.addAttribute(XMLString(), XMLString(), attr3, CDATA, value3); if (data.empty()) { emptyElement(namespaceURI, localName, qname, attributes); } else { startElement(namespaceURI, localName, qname, attributes); characters(data); endElement(namespaceURI, localName, qname); } }
void CSAX2ParserNSP::HandleStartNamespace(const XML_Char* prefix, const XML_Char* uri) { m_namespaceSupport.PushContext(); m_namespaceSupport.DeclarePrefix((prefix ? XMLString(prefix) : EMPTY_STRING), (uri ? XMLString(uri) : EMPTY_STRING)); if (m_pContentHandler) m_pContentHandler->StartPrefixMapping((prefix ? XMLString(prefix) : EMPTY_STRING), (uri ? XMLString(uri) : EMPTY_STRING)); }
void doctypeWhitespace(const XMLCh* const chars, const XMLSize_t length) { this->get_override("doctypeWhitespace")(XMLString(chars), length); }
void doctypePI(const XMLCh* const target, const XMLCh* const data) { this->get_override("doctypePI")(XMLString(target), XMLString(data)); }
void insertData(XMLSize_t offset, const XMLCh *arg) { this->get_override("insertData")(offset, XMLString(arg)); }
bool isDefaultNamespace(const XMLCh* namespaceURI) const { return this->get_override("isDefaultNamespace")(XMLString(namespaceURI)); }
void* getFeature(const XMLCh* feature, const XMLCh* version) const { return this->get_override("getFeature")(XMLString(feature), XMLString(version)); }
void CSAX2ParserBase::HandleInternalParsedEntityDecl(const XML_Char* entityName, const XML_Char* replacementText, int replacementTextLength) { if (m_pDeclHandler) m_pDeclHandler->InternalEntityDecl(entityName, XMLString(replacementText, replacementTextLength)); }
void CSAX2ParserBase::HandleExternalParsedEntityDecl(const XML_Char* entityName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId) { XMLString strPublicId = publicId ? XMLString(publicId) : EMPTY_STRING; if (m_pDeclHandler) m_pDeclHandler->ExternalEntityDecl(entityName, publicId ? &strPublicId : NULL, systemId); }
int CSAX2ParserBase::HandleExternalEntityRef(const XML_Char* context, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId) { csl_assert (systemId != NULL); if (context == NULL && !m_includeExtParEntities) return 0; if (context != NULL && !m_includeExtGenEntities) return 0; CInputSource* pInputSource = NULL; XMLString resolvedSystemId; if (base) resolvedSystemId = ResolveSystemId(base, systemId); else resolvedSystemId = systemId; CEntityResolver* pEntityResolver = NULL; CEntityResolverImp defaultResolver; XMLString pId; if (publicId) pId = XMLString(publicId); if (m_pEntityResolver) { pInputSource = m_pEntityResolver->ResolveEntity(publicId ? &pId : NULL, resolvedSystemId); pEntityResolver = m_pEntityResolver; } if (!pInputSource && m_includeExtGenEntities) { pInputSource = defaultResolver.ResolveEntity(publicId ? &pId : NULL, resolvedSystemId); pEntityResolver = &defaultResolver; } if (pInputSource) { XML_Parser extParser = XML_ExternalEntityParserCreate(GetExpatParser(), context, 0); XML_SetBase(extParser, resolvedSystemId.c_str()); try { if (pInputSource->GetCharacterStream()) { ParseCharExternal(extParser, pInputSource->GetCharacterStream()); } else if (pInputSource->GetByteStream()) { ParseExternal(extParser, pInputSource->GetByteStream()); } else { throw CSAXParseException("no input stream", EMPTY_STRING, pInputSource->GetSystemId(), 0, 0, CXMLException(CXMLException::EXMLBadInputSource, string())); } } catch (CXMLException& e) { // cleanup before we propagate the exception pEntityResolver->DoneWithInputSource(pInputSource); XML_ParserFree(extParser); throw e; } pEntityResolver->DoneWithInputSource(pInputSource); XML_ParserFree(extParser); return 1; } else { return 0; } }
DOMText* replaceWholeText(const XMLCh* content) { return this->get_override("replaceWholeText")(XMLString(content)); }
void CSAX2ParserNSP::HandleEndNamespace(const XML_Char* prefix) { m_namespaceSupport.PopContext(); if (m_pContentHandler) m_pContentHandler->EndPrefixMapping((prefix ? XMLString(prefix) : EMPTY_STRING)); }
const XMLCh* lookupNamespaceURI(const XMLCh* prefix) const { return this->get_override("lookupNamespaceURI")(XMLString(prefix)); }
void TextDecl(const XMLCh* const versionStr, const XMLCh* const encodingStr) { this->get_override("TextDecl")(XMLString(versionStr), XMLString(encodingStr)); }
const XMLCh* lookupPrefix(const XMLCh* namespaceURI) const { return this->get_override("lookupPrefix")(XMLString(namespaceURI)); }
void doctypeComment(const XMLCh* const comment) { this->get_override("doctypeComment")(XMLString(comment)); }
void doctypeDecl(const xercesc::DTDElementDecl& elemDecl, const XMLCh* const publicId, const XMLCh* const systemId, const bool hasIntSubset, const bool hasExtSubset = false) { this->get_override("doctypeDecl")(boost::ref(elemDecl), XMLString(publicId), XMLString(systemId), hasIntSubset, hasExtSubset); }
void appendData(const XMLCh *arg) { this->get_override("appendData")(XMLString(arg)); }