示例#1
0
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);
		}
	}
}
示例#2
0
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);
	}
}
示例#3
0
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);
}
示例#4
0
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);
}
示例#5
0
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));
}
示例#6
0
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);
}
示例#7
0
XMLString CAttributeListImp::GetValue(const XMLString& name) const
{
	Attrib* pAttr = Find(name);
	if (pAttr)
		return pAttr->m_value;
	else
		return XMLString();
}
示例#8
0
文件: Name.cpp 项目: hhawk51/georest
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;
}
示例#9
0
文件: Name.cpp 项目: hhawk51/georest
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;
}
示例#10
0
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());
}
示例#11
0
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);
    }
}
示例#13
0
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);
	}
}
示例#14
0
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));
}
示例#15
0
void doctypeWhitespace(const XMLCh* const chars, const XMLSize_t length) {
	this->get_override("doctypeWhitespace")(XMLString(chars), length);
}
示例#16
0
void doctypePI(const XMLCh* const target, const XMLCh* const data) {
	this->get_override("doctypePI")(XMLString(target), XMLString(data));
}
示例#17
0
void insertData(XMLSize_t offset, const XMLCh *arg) {
	this->get_override("insertData")(offset, XMLString(arg));
}
示例#18
0
bool isDefaultNamespace(const XMLCh* namespaceURI) const {
	return this->get_override("isDefaultNamespace")(XMLString(namespaceURI));
}
示例#19
0
void* getFeature(const XMLCh* feature, const XMLCh* version) const {
	return this->get_override("getFeature")(XMLString(feature), XMLString(version));
}
示例#20
0
void CSAX2ParserBase::HandleInternalParsedEntityDecl(const XML_Char* entityName, const XML_Char* replacementText, int replacementTextLength)
{
	if (m_pDeclHandler) m_pDeclHandler->InternalEntityDecl(entityName, XMLString(replacementText, replacementTextLength));
}
示例#21
0
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);
}
示例#22
0
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;
	}
}
示例#23
0
DOMText* replaceWholeText(const XMLCh* content) {
	return this->get_override("replaceWholeText")(XMLString(content));
}
示例#24
0
void CSAX2ParserNSP::HandleEndNamespace(const XML_Char* prefix)
{
	m_namespaceSupport.PopContext();
	if (m_pContentHandler) m_pContentHandler->EndPrefixMapping((prefix ? XMLString(prefix) : EMPTY_STRING));
}
示例#25
0
const XMLCh* lookupNamespaceURI(const XMLCh* prefix) const  {
	return this->get_override("lookupNamespaceURI")(XMLString(prefix));
}
示例#26
0
void TextDecl(const XMLCh* const versionStr, const XMLCh* const encodingStr) {
	this->get_override("TextDecl")(XMLString(versionStr), XMLString(encodingStr));
}
示例#27
0
const XMLCh* lookupPrefix(const XMLCh* namespaceURI) const {
	return this->get_override("lookupPrefix")(XMLString(namespaceURI));
}
示例#28
0
void doctypeComment(const XMLCh* const comment) {
	this->get_override("doctypeComment")(XMLString(comment));
}
示例#29
0
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);
}
示例#30
0
void appendData(const XMLCh *arg) {
	this->get_override("appendData")(XMLString(arg));
}