/***********************************************************************//** * @brief Write XML text into URL * * @param[in] url Unified Resource Locator. * @param[in] indent Text indentation (parameter ignored). * * Writes the text into the URL. ***************************************************************************/ void GXmlText::write(GUrl& url, const int& indent) const { // Write text url.printf("%s", m_text.c_str()); // Return return; }
/***********************************************************************//** * @brief Write XML text into URL * * @param[in] url Unified Resource Locator. * @param[in] indent Text indentation (parameter ignored). * * Writes the text into the URL. Special characters are automatically * transformed into predefined entities (e.g. "). ***************************************************************************/ void GXmlText::write(GUrl& url, const int& indent) const { // Write text url.printf("%s", gammalib::str2xml(m_text).c_str()); // Return return; }
/***********************************************************************//** * @brief Write element into URL * * @param[in] url Unified Resource Locator. * @param[in] indent Text indentation. * * Writes the element into a Unified Resource Locator. ***************************************************************************/ void GXmlElement::write(GUrl& url, const int& indent) const { // Prepend indentation for (int k = 0; k < indent; ++k) { url.printf(" "); } // Write element name into URL url.printf("<%s", m_name.c_str()); // Write attributes into URL for (int k = 0; k < m_attr.size(); ++k) { m_attr[k]->write(url); } // If there are no children then write an empty tag if (is_empty()) { url.printf(" />\n"); } // ... otherwise finish start tag, write children and write end tag else { // Case A: The element contains a single text leaf if ((m_nodes.size() == 1) && (m_nodes[0]->type() == NT_TEXT)) { // Finish start tag url.printf(">"); // Write text leaf m_nodes[0]->write(url, 0); // Write end tag url.printf("</%s>\n", m_name.c_str()); } // Case B: ... otherwise it contains markup else { // Finish start tag url.printf(">\n"); // Write children in file for (int i = 0; i < m_nodes.size(); ++i) { m_nodes[i]->write(url, indent+g_indent); if (m_nodes[i]->type() == NT_TEXT) { url.printf("\n"); } } // Write end tag for (int k = 0; k < indent; ++k) { url.printf(" "); } url.printf("</%s>\n", m_name.c_str()); } // endelse: element contained markup } // endelse: finished start tag // Return return; }