<commit_before>
#include <string.h>
#include "atXMLDocument.h++"


atXMLDocument::atXMLDocument(atXMLDocumentDocPtr doc)
{
   // Save a pointer to the XML document
   xml_doc = (xmlDocPtr ) doc;

   // Initialize the value for holding temp strings
   string_value = new atString();

   // Initialize the xml text pointer
   xml_text = NULL;
}


atXMLDocument::atXMLDocument(atXMLDocument * doc)
{
   // Save a pointer to the XML document of the document we are copying
   xml_doc = xmlCopyDoc(doc->xml_doc, 1);

   // Initialize the value for holding temp strings
   string_value = new atString();

   // Initialize the xml text pointer
   xml_text = NULL;
}


atXMLDocument::~atXMLDocument()
{
   // Free up the text buffer 
   if (xml_text != NULL)
      xmlFree(xml_text);

   // Free up the temp string
   if (string_value != NULL)
      delete string_value;

   // Free the XML document itself
   xmlFreeDoc(xml_doc);
}


atXMLDocumentDocPtr atXMLDocument::getDoc()
{
   // Return the base xml doc
   return xml_doc;
}


atXMLDocumentNodePtr atXMLDocument::getRootNode()
{
   // Get the root node pointer and return it
   return (atXMLDocumentNodePtr ) xmlDocGetRootElement(xml_doc);
}


atXMLDocumentNodePtr atXMLDocument::getNextSiblingNode(
   atXMLDocumentNodePtr node)
{
   xmlNodePtr   xmlNode;

   // Get the next sibling node of this node and return it
   xmlNode = (xmlNodePtr ) node;
   return (atXMLDocumentNodePtr ) node->next;
}


atXMLDocumentNodePtr atXMLDocument::getNextChildNode(atXMLDocumentNodePtr node)
{
   xmlNodePtr   xmlNode;
                                                                                
   // Get the child node of this node and return it
   xmlNode = (xmlNodePtr ) node;
   return (atXMLDocumentNodePtr ) node->xmlChildrenNode;
}


char * atXMLDocument::getNodeName(atXMLDocumentNodePtr node)
{
   return (char * ) ((xmlNodePtr ) node)->name;
}


char * atXMLDocument::getNodeAttribute(atXMLDocumentNodePtr node, 
                                       char *attrName)
{
   char *   prop;

   // Get the property
   prop = (char *) xmlGetProp(node, (const xmlChar *) attrName);

   // Copy the property value into our internal string
   if (prop != NULL)
      string_value->setString(prop);
   else
      string_value->setString("");

   // Free up the XML structure
   if (prop != NULL)
      xmlFree((xmlChar *) prop);

   // Return the string
   return string_value->getString();
}


char * atXMLDocument::getNodeText(atXMLDocumentNodePtr node)
{
   char *   str;

   // Get the string
   str = (char *) xmlNodeListGetString(xml_doc, node, 1);<commit_msg>Alter setting that tells libxml2 whether to rewrite the XML or not.<commit_after>
#include <string.h>
#include "atXMLDocument.h++"


atXMLDocument::atXMLDocument(atXMLDocumentDocPtr doc)
{
   // Save a pointer to the XML document
   xml_doc = (xmlDocPtr ) doc;

   // Initialize the value for holding temp strings
   string_value = new atString();

   // Initialize the xml text pointer
   xml_text = NULL;
}


atXMLDocument::atXMLDocument(atXMLDocument * doc)
{
   // Save a pointer to the XML document of the document we are copying
   xml_doc = xmlCopyDoc(doc->xml_doc, 1);

   // Initialize the value for holding temp strings
   string_value = new atString();

   // Initialize the xml text pointer
   xml_text = NULL;
}


atXMLDocument::~atXMLDocument()
{
   // Free up the text buffer 
   if (xml_text != NULL)
      xmlFree(xml_text);

   // Free up the temp string
   if (string_value != NULL)
      delete string_value;

   // Free the XML document itself
   xmlFreeDoc(xml_doc);
}


atXMLDocumentDocPtr atXMLDocument::getDoc()
{
   // Return the base xml doc
   return xml_doc;
}


atXMLDocumentNodePtr atXMLDocument::getRootNode()
{
   // Get the root node pointer and return it
   return (atXMLDocumentNodePtr ) xmlDocGetRootElement(xml_doc);
}


atXMLDocumentNodePtr atXMLDocument::getNextSiblingNode(
   atXMLDocumentNodePtr node)
{
   xmlNodePtr   xmlNode;

   // Get the next sibling node of this node and return it
   xmlNode = (xmlNodePtr ) node;
   return (atXMLDocumentNodePtr ) node->next;
}


atXMLDocumentNodePtr atXMLDocument::getNextChildNode(atXMLDocumentNodePtr node)
{
   xmlNodePtr   xmlNode;
                                                                                
   // Get the child node of this node and return it
   xmlNode = (xmlNodePtr ) node;
   return (atXMLDocumentNodePtr ) node->xmlChildrenNode;
}


char * atXMLDocument::getNodeName(atXMLDocumentNodePtr node)
{
   return (char * ) ((xmlNodePtr ) node)->name;
}


char * atXMLDocument::getNodeAttribute(atXMLDocumentNodePtr node, 
                                       char *attrName)
{
   char *   prop;

   // Get the property
   prop = (char *) xmlGetProp(node, (const xmlChar *) attrName);

   // Copy the property value into our internal string
   if (prop != NULL)
      string_value->setString(prop);
   else
      string_value->setString("");

   // Free up the XML structure
   if (prop != NULL)
      xmlFree((xmlChar *) prop);

   // Return the string
   return string_value->getString();
}


char * atXMLDocument::getNodeText(atXMLDocumentNodePtr node)
{
   char *   str;

   // Get the string
   str = (char *) xmlNodeListGetString(xml_doc, node, 0);
{'fraction_non_alphanumeric': 0.09271899886234357, 'fraction_numerical': 0.0009480470231323473, 'mean_word_length': 2.9161098737936153, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 69}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '882359', 'n_tokens_mistral': 1594, 'n_tokens_neox': 1544, 'n_words': 462}