XML_C14N_EXCLUSIVE_1_0;
133 while(k !=
n.end()) {
146 n.get_attributes().sort();
153 n.sort_namespace_definitions();
171 intoptions = XML_PARSE_HUGE | XML_PARSE_NODICT;
179options |= XML_PARSE_DTDLOAD;
187options |= XML_PARSE_NOBLANKS;
194options |= XML_PARSE_DTDVALID;
202options |= XML_PARSE_NOENT;
205xmlCtxtUseOptions(ctxt, options);
211 const charconst_default_encoding[] =
"ISO-8859-1";
214 extern "C" voidcb_dtd_valid_error (
void*v,
const char*message, ...);
215 extern "C" voidcb_dtd_valid_warning (
void*v,
const char*message, ...);
218 extern "C" voidcb_tree_parser_fatal_error (
void*v,
219 const char*message, ...);
220 extern "C" voidcb_tree_parser_error (
void*v,
const char*message, ...);
221 extern "C" voidcb_tree_parser_warning (
void*v,
const char*message, ...);
222 extern "C" voidcb_tree_parser_ignore (
void*,
constxmlChar*,
int);
238 const char*filename,
242xmlParserCtxtPtr ctxt;
244ctxt = xmlCreateFileParserCtxt(filename);
253 if(ctxt->sax !=
NULL)
259ctxt->_private =
data;
261 if(ctxt->directory ==
NULL)
262ctxt->directory = xmlParserGetDirectory(filename);
264xmlParseDocument(ctxt);
265 if(ctxt->wellFormed) {
268 if(ctxt->input->buf->compressed > 0)
269ret->compression = 9;
271ret->compression = ctxt->input->buf->compressed;
276xmlFreeDoc(ctxt->myDoc);
281xmlFreeParserCtxt(ctxt);
295memset(&sax, 0,
sizeof(sax));
296initxmlDefaultSAXHandler(&sax, 0);
298sax.warning = cb_tree_parser_warning;
299sax.error = cb_tree_parser_error;
300sax.fatalError = cb_tree_parser_fatal_error;
303sax.ignorableWhitespace = cb_tree_parser_ignore;
306std::unique_ptr<error_messages> msgs;
321FILE *
test(fopen(filename,
"r"));
333 if(tmpdoc) xmlFreeDoc(tmpdoc);
350xmlParserCtxtPtr ctxt = xmlCreateMemoryParserCtxt(
data,
352 "memory buffer is too large"));
354 throwstd::bad_alloc();
359memset(&sax, 0,
sizeof(sax));
360initxmlDefaultSAXHandler(&sax, 0);
362sax.warning = cb_tree_parser_warning;
363sax.error = cb_tree_parser_error;
364sax.fatalError = cb_tree_parser_fatal_error;
367sax.ignorableWhitespace = cb_tree_parser_ignore;
374std::unique_ptr<error_messages> msgs;
379ctxt->_private = temp;
383 intret(xmlParseDocument(ctxt));
386 if(!ctxt->wellFormed || ret != 0 ||
is_failure(temp, how)) {
388xmlFreeDoc(ctxt->myDoc);
390xmlFreeParserCtxt(ctxt);
399xmlFreeParserCtxt(ctxt);
407std::unique_ptr<doc_impl> ap(pimpl_ =
new doc_impl);
408pimpl_->set_root_node(
n);
430memset(&sax, 0,
sizeof(sax));
431initxmlDefaultSAXHandler(&sax, 0);
433sax.warning = cb_tree_parser_warning;
434sax.error = cb_tree_parser_error;
435sax.fatalError = cb_tree_parser_fatal_error;
439sax.ignorableWhitespace = cb_tree_parser_ignore;
443std::unique_ptr<error_messages> msgs;
450 if(stream && (stream.eof() ||
451stream.peek() == std::istream::traits_type::eof()))
460xmlParserCtxtPtr ctxt = xmlCreatePushParserCtxt(&sax, 0, 0, 0, 0);
462 throwstd::bad_alloc();
463ctxt->_private = temp;
474 if(xmlParseChunk(ctxt,
buffer,
static_cast<int>(stream.gcount()), 0) != 0)
477xmlParseChunk(ctxt, 0, 0, 1);
481 if(!ctxt->wellFormed || ctxt->myDoc ==
NULL||
is_failure(temp, how))
484xmlFreeDoc(ctxt->myDoc);
485xmlFreeParserCtxt(ctxt);
494xmlFreeParserCtxt(ctxt);
498pimpl_(new
doc_impl(*(other.pimpl_)))
516other.pimpl_ =
NULL;
521 if(
this!= &other) {
525other.pimpl_ =
NULL;
540pimpl_->root_.
set_node_data(xmlDocGetRootElement(pimpl_->doc_));
541 returnpimpl_->root_;
545pimpl_->root_.
set_node_data(xmlDocGetRootElement(pimpl_->doc_));
546 returnpimpl_->root_;
550pimpl_->set_root_node(
n);
554 returnpimpl_->version_;
558 constxmlChar * old_version = pimpl_->doc_->version;
560pimpl_->doc_->version = xmlStrdup(
561 reinterpret_cast<constxmlChar*
>(
version));
563 if( pimpl_->doc_->version == 0)
564 throwstd::bad_alloc();
568xmlFree(
const_cast<char*
>(
reinterpret_cast<const char*
>(old_version)));
572 if(pimpl_->encoding_.empty())
573pimpl_->encoding_ = const_default_encoding;
574 returnpimpl_->encoding_;
578pimpl_->encoding_ = encoding;
580 if(pimpl_->doc_->encoding)
581xmlFree(
const_cast<xmlChar*
>(pimpl_->doc_->encoding));
583pimpl_->doc_->encoding = xmlStrdup(
584 reinterpret_cast<constxmlChar*
>(encoding));
586 if(!pimpl_->doc_->encoding)
587 throwstd::bad_alloc();
591 returnpimpl_->doc_->standalone == 1;
595pimpl_->doc_->standalone = sa ? 1 : 0;
600 returnxmlXIncludeProcess(pimpl_->doc_) >= 0;
604 returnpimpl_->doc_->intSubset != 0;
608 if(!has_internal_subset())
609 throw xml::exception(
"The document does not have internal subset.");
610pimpl_->internal_subset_.set_dtd_data(pimpl_->doc_->intSubset);
611 returnpimpl_->internal_subset_;
615 returnpimpl_->doc_->extSubset != 0;
619 if(!has_external_subset())
620 throw xml::exception(
"The document does not have external subset.");
621pimpl_->external_subset_.set_dtd_data(pimpl_->doc_->extSubset);
622 returnpimpl_->external_subset_;
628std::unique_ptr<error_messages> msgs;
634memset(&vctxt, 0,
sizeof(vctxt));
635vctxt.error = cb_dtd_valid_error;
636vctxt.warning = cb_dtd_valid_warning;
637vctxt.userData = temp;
643 intretCode = xmlValidateDocument(&vctxt,
pimpl_->
doc_);
659 returndtd_.
validate(*
this, messages_, how);
664 returnschema_.
validate(*
this, messages_, how);
670 "dtd is not loaded");
672xmlDtdPtr
copy= xmlCopyDtd(
684 #ifdef NCBI_COMPILER_WORKSHOP 714 "can't take element type nodes");
716 static_cast<xmlNodePtr
>(
723 "can't take element type nodes");
727 static_cast<xmlNodePtr
>(
735 "can't take element type nodes");
738 static_cast<xmlNodePtr
>(
740 static_cast<xmlNodePtr
>(
745 const node&new_node) {
749 "can't replace element type nodes");
755 static_cast<xmlNodePtr
>(
762 "can't erase element type nodes");
765 static_cast<xmlNodePtr
>(to_erase.
get_raw_node())));
777 intcompression_level =
flags& 0xFFFF;
784 if(pimpl_->xslt_stylesheet_ != 0) {
786 std::swap(pimpl_->doc_->compression, compression_level);
788pimpl_->xslt_stylesheet_, s);
789 std::swap(pimpl_->doc_->compression, compression_level);
798 const char*enc = pimpl_->encoding_.empty() ? 0 : pimpl_->encoding_.c_str();
800enc, libxml2_options);
803 std::swap(pimpl_->doc_->compression, compression_level);
804xmlSaveDoc(ctxt, pimpl_->doc_);
805 std::swap(pimpl_->doc_->compression, compression_level);
817 if(pimpl_->xslt_stylesheet_ != 0)
820 "it holds xslt transformation results " 821 "which are not an xml");
823 intlibxml2_mode = -1;
827 intlibxml2_with_comments = 0;
829libxml2_with_comments = 1;
852tmp_doc =
document(serialized_doc.c_str(), serialized_doc.size(),
NULL,
872tmp_doc =
document(serialized_doc.c_str(), serialized_doc.size(),
NULL,
879 if(libxml2_mode != -1) {
884 NULL, libxml2_with_comments,
888 "failed to canonicalize");
890 str.assign(
reinterpret_cast<const char*
>(
result),
size);
924 intcompression_level =
flags& 0xFFFF;
929 if(pimpl_->xslt_stylesheet_ != 0) {
931 std::swap(pimpl_->doc_->compression, compression_level);
934pimpl_->xslt_stylesheet_, s);
936 std::swap(pimpl_->doc_->compression, compression_level);
945 const char*enc = pimpl_->encoding_.empty() ? 0 : pimpl_->encoding_.c_str();
947enc, libxml2_options);
950 std::swap(pimpl_->doc_->compression, compression_level);
951xmlSaveDoc(ctxt, pimpl_->doc_);
952 std::swap(pimpl_->doc_->compression, compression_level);
955 std::swap(pimpl_->doc_->compression, compression_level);
961 intcompression_level =
flags& 0xFFFF;
966 if(pimpl_->xslt_stylesheet_ != 0) {
968 std::swap(pimpl_->doc_->compression, compression_level);
970pimpl_->xslt_stylesheet_,
971filename, compression_level);
972 std::swap(pimpl_->doc_->compression, compression_level);
981 const char*enc = pimpl_->encoding_.empty() ? 0 : pimpl_->encoding_.c_str();
982xmlSaveCtxtPtr ctxt = xmlSaveToFilename(filename,
983enc, libxml2_options);
990 std::swap(pimpl_->doc_->compression, compression_level);
991rc = xmlSaveDoc(ctxt, pimpl_->doc_);
992 std::swap(pimpl_->doc_->compression, compression_level);
1000pimpl_->set_doc_data(
static_cast<xmlDocPtr
>(
data),
false);
1002 if(pimpl_->xslt_stylesheet_)
1003 if(pimpl_->xslt_stylesheet_->_private)
1005(pimpl_->xslt_stylesheet_->_private)->inc_ref();
1007pimpl_->xslt_stylesheet_ = 0;
1012xsltStylesheetPtr ss =
static_cast<xsltStylesheetPtr
>(ssheet);
1013pimpl_->set_doc_data(
static_cast<xmlDocPtr
>(
data),
false);
1014pimpl_->xslt_stylesheet_ = ss;
1017(ss->_private)->inc_ref();
1021 returnpimpl_->doc_;
1025 returnpimpl_->doc_;
1029xmlDocPtr xmldoc = pimpl_->doc_;
1063 #if LIBXML_VERSION >= 21200 1064 constxmlError * last_err = xmlGetLastError();
1067line = last_err->line;
1069 longline = xmlLastError.line;
1075 #if LIBXML_VERSION >= 21200 1077 if(last_err->file !=
NULL) {
1078filename = last_err->file;
1082 if(xmlLastError.file !=
NULL)
1083filename = xmlLastError.file;
1088 #if LIBXML_VERSION >= 21200 1089xmlResetLastError();
1095 extern "C" voidcb_dtd_valid_error (
void*v,
const char*message, ...) {
1099va_start(ap, message);
1106 extern "C" voidcb_dtd_valid_warning (
void*v,
const char*message, ...) {
1110va_start(ap, message);
1122xmlParserCtxtPtr ctxt =
static_cast<xmlParserCtxtPtr
>(v);
1127 #if LIBXML_VERSION >= 21200 1128 constxmlError * last_err = xmlGetLastError();
1131line = last_err->line;
1133 longline = xmlLastError.line;
1139 #if LIBXML_VERSION >= 21200 1141 if(last_err->file !=
NULL) {
1142filename = last_err->file;
1146 if(xmlLastError.file !=
NULL)
1147filename = xmlLastError.file;
1152 #if LIBXML_VERSION >= 21200 1153xmlResetLastError();
1159 extern "C" voidcb_tree_parser_fatal_error (
void*v,
1160 const char*message, ...) {
1164va_start(ap, message);
1172 extern "C" voidcb_tree_parser_error (
void*v,
const char*message, ...) {
1176va_start(ap, message);
1183 extern "C" voidcb_tree_parser_warning (
void*v,
const char*message, ...) {
1187va_start(ap, message);
1194 extern "C" voidcb_tree_parser_ignore (
void*,
constxmlChar*,
int) {
The xml::document_proxy class to be a relay between XSLT results and the document.
The xml::document class is used to hold the XML tree and various bits of information about it.
bool has_internal_subset(void) const
Test to see if this document has an internal subset.
void set_external_subset(const dtd &dtd_)
Sets the document external subset.
node::iterator insert(const node &n)
Insert a new child node.
const std::string & get_encoding(void) const
Get the XML encoding for this document.
document(void)
Create a new XML document with the default settings.
void save_to_stream(std::ostream &stream, save_option_flags flags=save_op_default) const
Convert the XML document tree into XML text data and then insert it into the given stream.
void set_root_node(const node &n)
Set the root node to the given node.
bool get_is_standalone(void) const
Find out if the current document is a standalone document.
bool has_external_subset(void) const
Test to see if this document has an external subset.
node::iterator erase(node::iterator to_erase)
Erase the node that is pointed to by the given iterator.
const dtd & get_internal_subset(void) const
Provides the DTD data that is declared within the XML document itself.
void set_doc_data(void *data)
virtual ~document(void)
Clean up after an XML document object.
bool process_xinclude(void)
Walk through the document and expand <xi:include> elements.
void swap(document &other)
Swap one xml::document object for another.
void save_to_string(std::string &s, save_option_flags flags=save_op_default) const
Convert the XML document tree into XML text data and place it into the given string.
document & operator=(const document &other)
Copy another document object into this one using the assignment operator.
size_type size(void) const
Returns the number of child nodes of this document.
void set_version(const char *version)
Set the XML version number for this document.
std::size_t size_type
size type
bool save_to_file(const char *filename, save_option_flags flags=save_op_default) const
Convert the XML document tree into XML text data and place it into the given filename.
node::iterator replace(node::iterator old_node, const node &new_node)
Replace the node pointed to by the given iterator with another node.
void set_encoding(const char *encoding)
Set the XML encoding string.
void push_back(const node &child)
Add a child xml::node to this document.
bool is_failure(error_messages *messages, warnings_as_errors_type how) const
void * release_doc_data(void)
const dtd & get_external_subset(void) const
Provides the DTD data that is referenced from an external source, such as a file or URL.
const node & get_root_node(void) const
Get a reference to the root node of this document.
void set_doc_data_from_xslt(void *data, void *ssheet)
const std::string & get_version(void) const
Get the XML version for this document.
node::iterator begin(void)
Get an iterator to the first child node of this document.
document & assign(const document &other)
Copy another document object into this one.
void save_to_string_canonical(std::string &str, canonicalization_option c14n_option, canonicalization_comments_option comments_option, canonicalization_format_option format_option, canonicalization_node_sort_option node_sort_option) const
Convert the XML document tree into XML text data and place it into the given string.
void set_is_standalone(bool sa)
Set the standalone flag.
void * get_doc_data(void)
node::iterator end(void)
Get an iterator that points one past the last child node for this document.
void * get_doc_data_read_only(void) const
bool validate(error_messages *messages_=NULL, warnings_as_errors_type how=type_warnings_are_errors) const
Validate this document against the DTD that has been attached to it.
The xml::dtd class represents an XML dtd from a file.
bool validate(const document &doc, error_messages *messages, warnings_as_errors_type how=type_warnings_are_errors) const
Validate the given XML document.
void * get_raw_pointer(void) const
The xml::error_message class is used to store a single error message which may appear while parsing o...
message_type
A type for different type of errors.
@ type_fatal_error
fatal error
The xml::error_messages class is used to store all the error message which are collected while parsin...
bool has_fatal_errors(void) const
Check if there are fatal errors in the error messages.
const error_messages_type & get_messages(void) const
Get the error messages.
bool has_warnings(void) const
Check if there are warnings in the error messages.
bool has_errors(void) const
Check if there are errors in the error messages.
This exception class is thrown by xmlwrapp for all runtime XML-related errors along with the xml::par...
static bool get_load_external_subsets(void)
This member function provides the current value whether or not the XML parser should load external (D...
static bool get_remove_whitespace(void)
This member function provides the current setting of the XML parser which tells whether it should rem...
static bool get_validate_xml(void)
This member function provides the current value whether or not the XML parser should validate every X...
static void remove_whitespace(bool flag)
This member function controls whether or not the XML parser should remove ignorable whitespace around...
static bool get_substitute_entities(void)
This member function provides the current value whether or not the XML parser should substitute entit...
The xml::node::const_iterator provides a way to access children nodes similar to a standard C++ conta...
The xml::node::iterator provides a way to access children nodes similar to a standard C++ container.
void * get_raw_node(void) const
The xml::node class is used to hold information about one XML node.
node_type get_type(void) const
Get this node's "type".
const char * get_name(void) const
Get the name of this xml::node.
void set_node_data(void *data)
void * get_node_data(void) const
@ type_element
XML element such as "<chapter/>".
@ type_comment
XML comment.
The xml::parser_exception class is used to store parsing and validating exception information.
The xml::schema class represents an XML schema.
bool validate(const document &doc, error_messages *messages, warnings_as_errors_type how=type_warnings_are_errors) const
Validate the given XML document.
XML dtd API for XmlWrapp.
#define test(a, b, c, d, e)
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
static const char * str(char *buf, int n)
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
static int c14n_op_to_libxml2_op(xml::canonicalization_option op)
static void remove_comments_recursively(xml::node &n)
static void sort_attributes_recursively(xml::node &n)
static void sort_node_recursively(xml::node &n)
static void sort_namespace_definitions_recursively(xml::node &n)
static xmlDocPtr xmlSAXParseFileWithData_Custom(xmlSAXHandlerPtr sax, const char *filename, void *data)
static const std::size_t const_buffer_size
static void set_parser_context_options(xmlParserCtxtPtr ctxt)
This file contains the definition of the xml::document class.
This file contains the definition of the xml::exception class.
This file contains the definition of the xml::node class.
const string version
version string
const struct ncbi::grid::netcache::search::fields::SIZE size
int strcmp(const char *str1, const char *str2)
xmlNodePtr node_replace(xmlNodePtr old_node, xmlNodePtr new_node)
Replace a node with another one.
xmlNodePtr node_erase(xmlNodePtr to_erase)
Erase a node from the child list, and then free it from memory.
void clear_https_messages(void)
int save_to_string_cb(void *ctx, const char *buf, int len)
int convert_to_libxml2_save_options(int options)
void printf2string(std::string &s, const char *message, va_list ap)
int save_to_stream_cb(void *ctx, const char *buf, int len)
xmlNodePtr node_insert(xmlNodePtr parent, xmlNodePtr before, xmlNodePtr to_add)
Insert a node somewhere in the child list of a parent node.
void collect_https_messages(xml::error_messages &append_to)
int save_option_flags
Bitwise save options mask type and a compression level.
std::ostream & operator<<(std::ostream &stream, const document &doc)
canonicalization_comments_option
@ save_op_no_format
Do not format save output.
@ save_op_no_decl
Drop the xml declaration.
@ save_op_default
Default is:
canonicalization_option
Canonicalization mode.
@ c14n_1_1
C14N 1.1 spec.
@ c14n_exclusive_1_0
Exclusive C14N 1.0 spec.
@ sort_attr_and_ns
Essentially it is not a canonicalization.
@ c14n_1_0
Origianal C14N 1.0 spec.
@ sort_attr_and_ns_no_decl
Essentially it is not a canonicalization.
warnings_as_errors_type
A type for different approaches to process warnings.
@ type_warnings_not_errors
Do not treat warnings as errors.
@ type_warnings_are_errors
Treat warnings as errors.
int size_t_to_int_conversion(std::size_t value, const std::string &msg)
canonicalization_format_option
canonicalization_node_sort_option
bool is_xml_output_method(xsltStylesheetPtr ss)
bool save_to_file(xmlDocPtr doc, xsltStylesheetPtr ss, const char *filename, int)
void save_to_string(xmlDocPtr doc, xsltStylesheetPtr ss, std::string &s)
Front end for a platform-specific configuration summary.
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
This file contains the definition of the xml::node manipulation functions.
XML schema API for XmlWrapp.
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
This file contains definition of the xslt::impl::stylesheet_impl class.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4