2
#include "rapidxml-1.13/rapidxml.hpp"
#include "rapidxml-1.13/rapidxml_print.hpp"
#include "rapidxml-1.13/rapidxml_utils.hpp"
#include <iostream>
#include <stdio.h>
using namespace std;

using namespace rapidxml;

int main()
{

    std::ofstream theFile ("trial.xml");
    xml_document<> doc;
    xml_node<>* decl = doc.allocate_node(node_declaration);
    decl->append_attribute(doc.allocate_attribute("version", "1.0"));
    decl->append_attribute(doc.allocate_attribute("encoding", "UTF-8"));
    doc.append_node(decl);
    xml_node<>* root = doc.allocate_node(node_element, "page");
    root->append_attribute(doc.allocate_attribute("xmlns", "http://ALTEC-Center.org/xsd/ocr-annotation-1-0.xsd"));
    root->append_attribute(doc.allocate_attribute("Number of lines", "10"));
    doc.append_node(root);
    for (int i = 0; i < 8; i++)
    {
        //char  buf1[8];
        //std::sprintf(buf1, "%d", i);
        xml_node<>* child = doc.allocate_node(node_element, "line");
        char * idxStr = doc.allocate_string("gvs");
        child->append_attribute(doc.allocate_attribute("Index",idxStr));
        root->append_node(child);

        for (int j = 0; j < 8; j++)
        {
            xml_node<>* child1 = doc.allocate_node(node_element, "word");
            child1->append_attribute(doc.allocate_attribute("Index","asdvs"));
            child1->append_attribute(doc.allocate_attribute("x","0.0"));
            child1->append_attribute(doc.allocate_attribute("y","0.1"));
            child1->append_attribute(doc.allocate_attribute("width","0.2"));
            child1->append_attribute(doc.allocate_attribute("hight","0.3"));
            child1->append_attribute(doc.allocate_attribute("word","محمد"));
            child->append_node(child1);
        }
    }
    theFile << doc;
    theFile.close();
    doc.clear();

    return 0;
}

/on running the code I am getting the following error: ‘print_children’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]|/

Pratik Gadoya
  • 1,356
  • 1
  • 14
  • 24

1 Answers1

0

This looks like a bug in rapidxml 1.13. This is the bug entry:

https://sourceforge.net/p/rapidxml/bugs/16/

It is marked for clang++ in 2011 when it workd for GCC. It may be that newer versions of GCC break in the same way clang++ used to:

print_node() is referring to other methods that are not yet defined (they are defined immediately below). I solved this by moving the impl of print_node() down below its brethren print_children(), print_element_node() et al, and put a forward decl of print_node() at the top. My diff attached. The rev numbers in the diff are from my vcs.

Clang appears to be more picky about language rules than gcc, and I rather like that, FWIW.

Perhaps GCC and other compilers are now "picky about language rules" enough to pick up this bug?

Galik
  • 42,526
  • 3
  • 76
  • 100