Esempio n. 1
0
static ne_xml_parser *
error_parser_create(svn_ra_neon__request_t *req)
{
  error_parser_baton_t *b = apr_palloc(req->pool, sizeof(*b));
  ne_xml_parser *error_parser;

  b->dst_err = &(req->err);
  b->marshalled_error = &(req->marshalled_error);
  b->tmp_err = NULL;

  b->want_cdata = NULL;
  b->cdata = svn_stringbuf_create("", req->pool);

  /* attach a standard <D:error> body parser to the request */
  error_parser = xml_parser_create(req);
  ne_xml_push_handler(error_parser,
                      start_err_element,
                      collect_error_cdata,
                      end_err_element, b);

  apr_pool_cleanup_register(req->pool, b,
                            error_parser_baton_cleanup,
                            apr_pool_cleanup_null);

  /* Register the "error" accepter and body-reader with the request --
     the one to use when HTTP status is *not* 2XX */
  attach_ne_body_reader(req, ra_neon_error_accepter,
                        ne_xml_parse_v, error_parser);

  return error_parser;
}
Esempio n. 2
0
ne_xml_parser *
svn_ra_neon__xml_parser_create(svn_ra_neon__request_t *req,
                               ne_accept_response accpt,
                               svn_ra_neon__startelm_cb_t startelm_cb,
                               svn_ra_neon__cdata_cb_t cdata_cb,
                               svn_ra_neon__endelm_cb_t endelm_cb,
                               void *baton)
{
  ne_xml_parser *p = xml_parser_create(req);
  parser_wrapper_baton_t *pwb = apr_palloc(req->pool, sizeof(*pwb));

  pwb->req = req;
  pwb->parser = p;
  pwb->baton = baton;
  pwb->startelm_cb = startelm_cb;
  pwb->cdata_cb = cdata_cb;
  pwb->endelm_cb = endelm_cb;

  ne_xml_push_handler(p,
                      wrapper_startelm_cb,
                      wrapper_cdata_cb,
                      wrapper_endelm_cb, pwb);

  if (accpt)
    attach_ne_body_reader(req, accpt, wrapper_reader_cb, pwb);

  return p;
}
Esempio n. 3
0
int main(int argc, char* argv[])
{
	XmlParser* thiz = xml_parser_create();
	XmlBuilder* builder = xml_builder_tree_create();

	xml_parser_set_builder(thiz, builder);

	if(argc > 1)
	{
		char* buffer = read_file(argv[1]);
		xml_parser_parse(thiz, buffer);
		free(buffer);
	}

	XmlNode* tree = xml_builder_get_tree(builder);
	dump_tree(tree);
	xml_node_destroy(tree);

	xml_builder_destroy(builder);
	xml_parser_destroy(thiz);

	return 0;
}