A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/misc_2xmlwrapp_2document_8cpp_source.html below:

NCBI C++ ToolKit: src/misc/xmlwrapp/document.cpp Source File

66 #include <libxml/parser.h> 67 #include <libxml/parserInternals.h> 68 #include <libxml/SAX.h> 69 #include <libxml/xmlversion.h> 70 #include <libxml/tree.h> 71 #include <libxml/xinclude.h> 72 #include <libxml/xmlsave.h> 73 #include <libxml/c14n.h> 89 #if LIBXML_VERSION >= 20600 90 # define initxmlDefaultSAXHandler xmlSAX2InitDefaultSAXHandler 91 # include <libxml/SAX2.h> 104  return

XML_C14N_EXCLUSIVE_1_0;

133  while

(k !=

n

.end()) {

146  n

.get_attributes().sort();

153  n

.sort_namespace_definitions();

171  int

options = XML_PARSE_HUGE | XML_PARSE_NODICT;

179

options |= XML_PARSE_DTDLOAD;

187

options |= XML_PARSE_NOBLANKS;

194

options |= XML_PARSE_DTDVALID;

202

options |= XML_PARSE_NOENT;

205

xmlCtxtUseOptions(ctxt, options);

211  const char

const_default_encoding[] =

"ISO-8859-1"

;

214  extern "C" void

cb_dtd_valid_error (

void

*v,

const char

*message, ...);

215  extern "C" void

cb_dtd_valid_warning (

void

*v,

const char

*message, ...);

218  extern "C" void

cb_tree_parser_fatal_error (

void

*v,

219  const char

*message, ...);

220  extern "C" void

cb_tree_parser_error (

void

*v,

const char

*message, ...);

221  extern "C" void

cb_tree_parser_warning (

void

*v,

const char

*message, ...);

222  extern "C" void

cb_tree_parser_ignore (

void

*,

const

xmlChar*,

int

);

238  const char

*filename,

242

xmlParserCtxtPtr ctxt;

244

ctxt = xmlCreateFileParserCtxt(filename);

253  if

(ctxt->sax !=

NULL

)

259

ctxt->_private =

data

;

261  if

(ctxt->directory ==

NULL

)

262

ctxt->directory = xmlParserGetDirectory(filename);

264

xmlParseDocument(ctxt);

265  if

(ctxt->wellFormed) {

268  if

(ctxt->input->buf->compressed > 0)

269

ret->compression = 9;

271

ret->compression = ctxt->input->buf->compressed;

276

xmlFreeDoc(ctxt->myDoc);

281

xmlFreeParserCtxt(ctxt);

295

memset(&sax, 0,

sizeof

(sax));

296

initxmlDefaultSAXHandler(&sax, 0);

298

sax.warning = cb_tree_parser_warning;

299

sax.error = cb_tree_parser_error;

300

sax.fatalError = cb_tree_parser_fatal_error;

303

sax.ignorableWhitespace = cb_tree_parser_ignore;

306

std::unique_ptr<error_messages> msgs;

321

FILE *

test

(fopen(filename,

"r"

));

333  if

(tmpdoc) xmlFreeDoc(tmpdoc);

350

xmlParserCtxtPtr ctxt = xmlCreateMemoryParserCtxt(

data

,

352  "memory buffer is too large"

));

354  throw

std::bad_alloc();

359

memset(&sax, 0,

sizeof

(sax));

360

initxmlDefaultSAXHandler(&sax, 0);

362

sax.warning = cb_tree_parser_warning;

363

sax.error = cb_tree_parser_error;

364

sax.fatalError = cb_tree_parser_fatal_error;

367

sax.ignorableWhitespace = cb_tree_parser_ignore;

374

std::unique_ptr<error_messages> msgs;

379

ctxt->_private = temp;

383  int

ret(xmlParseDocument(ctxt));

386  if

(!ctxt->wellFormed || ret != 0 ||

is_failure

(temp, how)) {

388

xmlFreeDoc(ctxt->myDoc);

390

xmlFreeParserCtxt(ctxt);

399

xmlFreeParserCtxt(ctxt);

407

std::unique_ptr<doc_impl> ap(pimpl_ =

new doc_impl

);

408

pimpl_->set_root_node(

n

);

430

memset(&sax, 0,

sizeof

(sax));

431

initxmlDefaultSAXHandler(&sax, 0);

433

sax.warning = cb_tree_parser_warning;

434

sax.error = cb_tree_parser_error;

435

sax.fatalError = cb_tree_parser_fatal_error;

439

sax.ignorableWhitespace = cb_tree_parser_ignore;

443

std::unique_ptr<error_messages> msgs;

450  if

(stream && (stream.eof() ||

451

stream.peek() == std::istream::traits_type::eof()))

460

xmlParserCtxtPtr ctxt = xmlCreatePushParserCtxt(&sax, 0, 0, 0, 0);

462  throw

std::bad_alloc();

463

ctxt->_private = temp;

474  if

(xmlParseChunk(ctxt,

buffer

,

static_cast<int>

(stream.gcount()), 0) != 0)

477

xmlParseChunk(ctxt, 0, 0, 1);

481  if

(!ctxt->wellFormed || ctxt->myDoc ==

NULL

||

is_failure

(temp, how))

484

xmlFreeDoc(ctxt->myDoc);

485

xmlFreeParserCtxt(ctxt);

494

xmlFreeParserCtxt(ctxt);

498

pimpl_(new

doc_impl

(*(other.pimpl_)))

516

other.pimpl_ =

NULL

;

521  if

(

this

!= &other) {

525

other.pimpl_ =

NULL

;

540

pimpl_->root_.

set_node_data

(xmlDocGetRootElement(pimpl_->doc_));

541  return

pimpl_->root_;

545

pimpl_->root_.

set_node_data

(xmlDocGetRootElement(pimpl_->doc_));

546  return

pimpl_->root_;

550

pimpl_->set_root_node(

n

);

554  return

pimpl_->version_;

558  const

xmlChar * old_version = pimpl_->doc_->version;

560

pimpl_->doc_->version = xmlStrdup(

561  reinterpret_cast<const

xmlChar*

>

(

version

));

563  if

( pimpl_->doc_->version == 0)

564  throw

std::bad_alloc();

568

xmlFree(

const_cast<char

*

>

(

reinterpret_cast<const char

*

>

(old_version)));

572  if

(pimpl_->encoding_.empty())

573

pimpl_->encoding_ = const_default_encoding;

574  return

pimpl_->encoding_;

578

pimpl_->encoding_ = encoding;

580  if

(pimpl_->doc_->encoding)

581

xmlFree(

const_cast<

xmlChar*

>

(pimpl_->doc_->encoding));

583

pimpl_->doc_->encoding = xmlStrdup(

584  reinterpret_cast<const

xmlChar*

>

(encoding));

586  if

(!pimpl_->doc_->encoding)

587  throw

std::bad_alloc();

591  return

pimpl_->doc_->standalone == 1;

595

pimpl_->doc_->standalone = sa ? 1 : 0;

600  return

xmlXIncludeProcess(pimpl_->doc_) >= 0;

604  return

pimpl_->doc_->intSubset != 0;

608  if

(!has_internal_subset())

609  throw xml::exception

(

"The document does not have internal subset."

);

610

pimpl_->internal_subset_.set_dtd_data(pimpl_->doc_->intSubset);

611  return

pimpl_->internal_subset_;

615  return

pimpl_->doc_->extSubset != 0;

619  if

(!has_external_subset())

620  throw xml::exception

(

"The document does not have external subset."

);

621

pimpl_->external_subset_.set_dtd_data(pimpl_->doc_->extSubset);

622  return

pimpl_->external_subset_;

628

std::unique_ptr<error_messages> msgs;

634

memset(&vctxt, 0,

sizeof

(vctxt));

635

vctxt.error = cb_dtd_valid_error;

636

vctxt.warning = cb_dtd_valid_warning;

637

vctxt.userData = temp;

643  int

retCode = xmlValidateDocument(&vctxt,

pimpl_

->

doc_

);

659  return

dtd_.

validate

(*

this

, messages_, how);

664  return

schema_.

validate

(*

this

, messages_, how);

670  "dtd is not loaded"

);

672

xmlDtdPtr

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  int

compression_level =

flags

& 0xFFFF;

784  if

(pimpl_->xslt_stylesheet_ != 0) {

786  std::swap

(pimpl_->doc_->compression, compression_level);

788

pimpl_->xslt_stylesheet_, s);

789  std::swap

(pimpl_->doc_->compression, compression_level);

798  const char

*enc = pimpl_->encoding_.empty() ? 0 : pimpl_->encoding_.c_str();

800

enc, libxml2_options);

803  std::swap

(pimpl_->doc_->compression, compression_level);

804

xmlSaveDoc(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  int

libxml2_mode = -1;

827  int

libxml2_with_comments = 0;

829

libxml2_with_comments = 1;

852

tmp_doc =

document

(serialized_doc.c_str(), serialized_doc.size(),

NULL

,

872

tmp_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  int

compression_level =

flags

& 0xFFFF;

929  if

(pimpl_->xslt_stylesheet_ != 0) {

931  std::swap

(pimpl_->doc_->compression, compression_level);

934

pimpl_->xslt_stylesheet_, s);

936  std::swap

(pimpl_->doc_->compression, compression_level);

945  const char

*enc = pimpl_->encoding_.empty() ? 0 : pimpl_->encoding_.c_str();

947

enc, libxml2_options);

950  std::swap

(pimpl_->doc_->compression, compression_level);

951

xmlSaveDoc(ctxt, pimpl_->doc_);

952  std::swap

(pimpl_->doc_->compression, compression_level);

955  std::swap

(pimpl_->doc_->compression, compression_level);

961  int

compression_level =

flags

& 0xFFFF;

966  if

(pimpl_->xslt_stylesheet_ != 0) {

968  std::swap

(pimpl_->doc_->compression, compression_level);

970

pimpl_->xslt_stylesheet_,

971

filename, compression_level);

972  std::swap

(pimpl_->doc_->compression, compression_level);

981  const char

*enc = pimpl_->encoding_.empty() ? 0 : pimpl_->encoding_.c_str();

982

xmlSaveCtxtPtr ctxt = xmlSaveToFilename(filename,

983

enc, libxml2_options);

990  std::swap

(pimpl_->doc_->compression, compression_level);

991

rc = xmlSaveDoc(ctxt, pimpl_->doc_);

992  std::swap

(pimpl_->doc_->compression, compression_level);

1000

pimpl_->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();

1007

pimpl_->xslt_stylesheet_ = 0;

1012

xsltStylesheetPtr ss =

static_cast<

xsltStylesheetPtr

>

(ssheet);

1013

pimpl_->set_doc_data(

static_cast<

xmlDocPtr

>

(

data

),

false

);

1014

pimpl_->xslt_stylesheet_ = ss;

1017

(ss->_private)->inc_ref();

1021  return

pimpl_->doc_;

1025  return

pimpl_->doc_;

1029

xmlDocPtr xmldoc = pimpl_->doc_;

1063  #if LIBXML_VERSION >= 21200 1064  const

xmlError * last_err = xmlGetLastError();

1067

line = last_err->line;

1069  long

line = xmlLastError.line;

1075  #if LIBXML_VERSION >= 21200 1077  if

(last_err->file !=

NULL

) {

1078

filename = last_err->file;

1082  if

(xmlLastError.file !=

NULL

)

1083

filename = xmlLastError.file;

1088  #if LIBXML_VERSION >= 21200 1089

xmlResetLastError();

1095  extern "C" void

cb_dtd_valid_error (

void

*v,

const char

*message, ...) {

1099

va_start(ap, message);

1106  extern "C" void

cb_dtd_valid_warning (

void

*v,

const char

*message, ...) {

1110

va_start(ap, message);

1122

xmlParserCtxtPtr ctxt =

static_cast<

xmlParserCtxtPtr

>

(v);

1127  #if LIBXML_VERSION >= 21200 1128  const

xmlError * last_err = xmlGetLastError();

1131

line = last_err->line;

1133  long

line = xmlLastError.line;

1139  #if LIBXML_VERSION >= 21200 1141  if

(last_err->file !=

NULL

) {

1142

filename = last_err->file;

1146  if

(xmlLastError.file !=

NULL

)

1147

filename = xmlLastError.file;

1152  #if LIBXML_VERSION >= 21200 1153

xmlResetLastError();

1159  extern "C" void

cb_tree_parser_fatal_error (

void

*v,

1160  const char

*message, ...) {

1164

va_start(ap, message);

1172  extern "C" void

cb_tree_parser_error (

void

*v,

const char

*message, ...) {

1176

va_start(ap, message);

1183  extern "C" void

cb_tree_parser_warning (

void

*v,

const char

*message, ...) {

1187

va_start(ap, message);

1194  extern "C" void

cb_tree_parser_ignore (

void

*,

const

xmlChar*,

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