Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

mlview-xml-document.c File Reference

#include <libxml/tree.h>
#include <libxml/valid.h>
#include "mlview-xml-document.h"
#include "mlview-parsing-utils.h"
#include "mlview-settings-management.h"
#include "mlview-file-selection.h"
#include "mlview-file-descriptor.h"
#include "mlview-global-settings.h"
#include "utils.h"

Go to the source code of this file.

Data Structures

struct  _MlViewXMLDocumentPrivate

Defines

#define PRIVATE(mlview_xml_doc)   (mlview_xml_doc->private)
#define MLVIEW_XML_DOCUMENT_DEFAULT_VALIDATION_ON   FALSE ;
#define MLVIEW_XML_DOCUMENT_NODE_CLIPBOARD_SIZE   128

Enumerations

enum  {
  DOCUMENT_CHANGED = 0, NODE_CUT, CHILD_NODE_ADDED, PREV_SIBLING_NODE_INSERTED,
  NEXT_SIBLING_NODE_INSERTED, CONTENT_CHANGED, NAME_CHANGED, NODE_CHANGED,
  FILE_PATH_CHANGED, NUMBER_OF_SIGNALS
}

Functions

guint mlview_xml_document_get_type (void)
MlViewXMLDocumentmlview_xml_document_new (xmlDocPtr a_xml_doc, MlViewAppContext *a_context)
void mlview_xml_document_set_app_context (MlViewXMLDocument *a_doc, MlViewAppContext *a_context)
MlViewAppContextmlview_xml_document_get_app_context (MlViewXMLDocument *a_doc)
void mlview_xml_document_copy_node_to_clipboard (xmlNode *a_xml_node, xmlDoc *a_doc)
 Stores the a copy of the xmlNode given in argument into the node clipboard.

xmlNode * mlview_xml_document_get_node_from_clipboard (xmlDoc *a_xml_doc)
MlViewXMLDocumentmlview_xml_document_open (gchar *a_file_name, MlViewAppContext *a_context)
 Opens the xml file contains in the filename given in parameter.

gint mlview_xml_document_associate_dtd_interactive (MlViewXMLDocument *a_doc)
 Associates a Dtd to the current xml document.

gint mlview_xml_document_associate_dtd (MlViewXMLDocument *a_doc, MlViewExternalSubsetDefinition *a_ext_subs_def)
 Associates a the dtd designated by a_ext_subs_def to the current xml document.

gint mlview_xml_document_validate (MlViewXMLDocument *a_doc)
 Validates the document agains the dtd that is associated to it.

gint mlview_xml_document_save (MlViewXMLDocument *a_doc)
gint mlview_xml_document_save_as (MlViewXMLDocument *a_doc, gchar *a_file_path)
MlViewXMLDocumentmlview_xml_document_clone (MlViewXMLDocument *a_original)
 Clones the current instance of MlViewXMLDocument.

void mlview_xml_document_set_file_path (MlViewXMLDocument *a_xml_doc, gchar *a_file_path)
gchar * mlview_xml_document_get_file_path (MlViewXMLDocument *a_xml_doc)
xmlNode * mlview_xml_document_add_child_node (MlViewXMLDocument *a_xml_doc, xmlNode *a_parent_xml_node, xmlNode *a_xml_node, gboolean a_subtree_required)
 Adds a child node to the a_parent_node node.

xmlNode * mlview_xml_document_cut_node (MlViewXMLDocument *a_xml_doc, xmlNode *a_xml_node)
 Cuts the node a_xml_node.

xmlNode * mlview_xml_document_set_node_content (MlViewXMLDocument *a_xml_document, xmlNode *a_node, gchar *a_content)
 Sets a new content a_content to a_node.

xmlNode * mlview_xml_document_set_node_name (MlViewXMLDocument *a_xml_document, xmlNode *a_node, gchar *a_name)
 Sets the name of a_node to a_name.

xmlNode * mlview_xml_document_insert_prev_sibling_node (MlViewXMLDocument *a_xml_document, xmlNode *a_sibling_node, xmlNode *a_xml_node, gboolean a_subtree_required)
 Inserts a_sibling_node as the previous sibling node of a_xml_node.

xmlNode * mlview_xml_document_insert_next_sibling_node (MlViewXMLDocument *a_xml_document, xmlNode *a_sibling_node, xmlNode *a_xml_node, gboolean a_subtree_required)
 Inserts a_sibling_node as the next sibling of a_xml_node.

void mlview_xml_document_paste_node_as_child (MlViewXMLDocument *a_xml_document, xmlNode *a_parent_node)
void mlview_xml_document_paste_node_as_sibling (MlViewXMLDocument *a_xml_document, xmlNode *a_parent_node, xmlNode *a_sibling_node, gboolean a_previous)
gboolean mlview_xml_document_needs_saving (MlViewXMLDocument *a_doc)
MlViewFileDescriptormlview_xml_document_get_file_descriptor (MlViewXMLDocument *a_xml_doc)
void mlview_xml_document_set_file_descriptor (MlViewXMLDocument *a_xml_doc, MlViewFileDescriptor *a_file_desc)
xmlDocPtr mlview_xml_document_get_xml_document (MlViewXMLDocument *a_xml_doc)
void mlview_xml_document_set_xml_document (MlViewXMLDocument *a_doc, xmlDocPtr a_mem_doc)


Define Documentation

#define MLVIEW_XML_DOCUMENT_DEFAULT_VALIDATION_ON   FALSE ;
 

Definition at line 66 of file mlview-xml-document.c.

#define MLVIEW_XML_DOCUMENT_NODE_CLIPBOARD_SIZE   128
 

Definition at line 79 of file mlview-xml-document.c.

#define PRIVATE mlview_xml_doc       (mlview_xml_doc->private)
 

Definition at line 65 of file mlview-xml-document.c.

Referenced by mlview_xml_document_add_child_node(), mlview_xml_document_associate_dtd_interactive(), mlview_xml_document_clone(), mlview_xml_document_cut_node(), mlview_xml_document_get_app_context(), mlview_xml_document_get_file_descriptor(), mlview_xml_document_get_file_path(), mlview_xml_document_insert_next_sibling_node(), mlview_xml_document_insert_prev_sibling_node(), mlview_xml_document_paste_node_as_child(), mlview_xml_document_paste_node_as_sibling(), mlview_xml_document_set_app_context(), mlview_xml_document_set_file_path(), and mlview_xml_document_validate().


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
DOCUMENT_CHANGED 
NODE_CUT 
CHILD_NODE_ADDED 
PREV_SIBLING_NODE_INSERTED 
NEXT_SIBLING_NODE_INSERTED 
CONTENT_CHANGED 
NAME_CHANGED 
NODE_CHANGED 
FILE_PATH_CHANGED 
NUMBER_OF_SIGNALS 

Definition at line 52 of file mlview-xml-document.c.


Function Documentation

xmlNode* mlview_xml_document_add_child_node MlViewXMLDocument   a_xml_doc,
xmlNode *    a_parent_xml_node,
xmlNode *    a_xml_node,
gboolean    a_subtree_required
 

Adds a child node to the a_parent_node node.

Parameters:
a_xml_node  the node to add.
a_xml_doc  the current instance of MlViewXMLDocument.
a_parent_node  the parent of the node to add.

Definition at line 713 of file mlview-xml-document.c.

References CHILD_NODE_ADDED, DOCUMENT_CHANGED, mlview_app_context_get_settings_value(), mlview_app_context_settings_exist(), MLVIEW_IS_XML_DOCUMENT, mlview_parsing_utils_build_required_attributes_list(), mlview_parsing_utils_build_required_children_tree(), MLVIEW_PARSING_UTILS_STATUS, and PRIVATE.

Referenced by mlview_editor_create_new_xml_document(), mlview_tree_editor_add_child_node(), and mlview_xml_document_paste_node_as_child().

gint mlview_xml_document_associate_dtd MlViewXMLDocument   a_doc,
MlViewExternalSubsetDefinition   a_ext_subs_def
 

Associates a the dtd designated by a_ext_subs_def to the current xml document.

Note that if the document contains is already associated to a dtd, the function asks the user if she wants to overide it. If the user agrees, the functions frees the former dtd and makes the new association. If not, nothing is done.

Returns:
0 if the association has been done, 1 if the user cancelled the operations,

Definition at line 487 of file mlview-xml-document.c.

References mlview_parsing_utils_load_a_dtd(), PRIVATE, and _MlViewExternalSubsetDefinition::system_id.

Referenced by mlview_xml_document_associate_dtd_interactive().

gint mlview_xml_document_associate_dtd_interactive MlViewXMLDocument   a_doc
 

Associates a Dtd to the current xml document.

If the document already contains a Dtd, this functions displays a dialog box to ask the user if he wants to overide that Dtd. Depending on the answer of the user, this function does the association or not.

Parameters:
a_doc  the current mlview xml document.
Returns:
0 if the association has been done, 1 if the user cancelled the operations,

Definition at line 458 of file mlview-xml-document.c.

References mlview_parsing_utils_let_user_choose_a_dtd(), mlview_xml_document_associate_dtd(), and PRIVATE.

Referenced by mlview_editor_associate_dtd_interactive(), and mlview_editor_create_new_xml_document().

MlViewXMLDocument* mlview_xml_document_clone MlViewXMLDocument   a_original
 

Clones the current instance of MlViewXMLDocument.

Parameters:
a_original  the current instance of MlViewXMLDocument.

Definition at line 646 of file mlview-xml-document.c.

References mlview_file_descriptor_get_file_path(), mlview_xml_document_get_file_descriptor(), mlview_xml_document_open(), and PRIVATE.

void mlview_xml_document_copy_node_to_clipboard xmlNode *    a_xml_node,
xmlDoc *    a_doc
 

Stores the a copy of the xmlNode given in argument into the node clipboard.

The cilpboard is a circular buffer. It cannot be overflowed.

Parameters:
a_visual_node  the pointer to xmlNode to store in the clipboard. If it is a NULL pointer, a NULL pointer is actually stored into clipboard.

Definition at line 379 of file mlview-xml-document.c.

Referenced by mlview_tree_editor_copy_node(), and mlview_xml_document_cut_node().

xmlNode* mlview_xml_document_cut_node MlViewXMLDocument   a_xml_doc,
xmlNode *    a_xml_node
 

Cuts the node a_xml_node.

The node is stored in the node clipboard and then unlinked from the xml tree.

Parameters:
a_xml_doc  the current xml node
Returns:
the xmlNode* cut or NULL if something bad happened.

Definition at line 772 of file mlview-xml-document.c.

References DOCUMENT_CHANGED, MLVIEW_IS_XML_DOCUMENT, mlview_xml_document_copy_node_to_clipboard(), NODE_CUT, and PRIVATE.

Referenced by mlview_tree_editor_cut_node().

MlViewAppContext* mlview_xml_document_get_app_context MlViewXMLDocument   a_doc
 

Parameters:
a_doc  the current xml document.

Definition at line 357 of file mlview-xml-document.c.

References PRIVATE.

Referenced by mlview_xml_document_view_set_name_interactive().

MlViewFileDescriptor* mlview_xml_document_get_file_descriptor MlViewXMLDocument   a_xml_doc
 

Parameters:
a_xml_doc 

Definition at line 1093 of file mlview-xml-document.c.

References PRIVATE.

Referenced by mlview_xml_document_clone(), mlview_xml_document_needs_saving(), mlview_xml_document_save(), and mlview_xml_document_view_get_file_descriptor().

gchar* mlview_xml_document_get_file_path MlViewXMLDocument   a_xml_doc
 

Parameters:
a_xml_doc 

Definition at line 694 of file mlview-xml-document.c.

References mlview_file_descriptor_get_file_path(), and PRIVATE.

Referenced by mlview_editor_get_current_xml_doc_file_path(), and mlview_xml_document_save_as().

xmlNode* mlview_xml_document_get_node_from_clipboard xmlDoc *    a_xml_doc
 

Parameters:
a_xml_doc  the destination document. Is usefull to know how to handle namespace copy stuffs.
Returns:
a different copy of the same xmlNode that has been previously stored.

Definition at line 401 of file mlview-xml-document.c.

Referenced by mlview_xml_document_paste_node_as_child(), and mlview_xml_document_paste_node_as_sibling().

guint mlview_xml_document_get_type void   
 

Definition at line 280 of file mlview-xml-document.c.

xmlDocPtr mlview_xml_document_get_xml_document MlViewXMLDocument   a_xml_doc
 

Parameters:
a_xml_doc 

Definition at line 1124 of file mlview-xml-document.c.

References PRIVATE.

Referenced by mlview_tree_editor_edit_xml_doc().

xmlNode* mlview_xml_document_insert_next_sibling_node MlViewXMLDocument   a_xml_document,
xmlNode *    a_sibling_node,
xmlNode *    a_xml_node,
gboolean    a_subtree_required
 

Inserts a_sibling_node as the next sibling of a_xml_node.

Parameters:
a_xml_node  the reference xml node.
a_xml_document  the current xml document.
a_sibling_node  the new sibling node to insert.
Returns:
the newly inserted next sibling node (a_sibling_node) or

Definition at line 936 of file mlview-xml-document.c.

References DOCUMENT_CHANGED, mlview_app_context_get_settings_value(), mlview_app_context_settings_exist(), MLVIEW_IS_XML_DOCUMENT, mlview_parsing_utils_build_required_attributes_list(), mlview_parsing_utils_build_required_children_tree(), MLVIEW_PARSING_UTILS_STATUS, NEXT_SIBLING_NODE_INSERTED, and PRIVATE.

Referenced by mlview_tree_editor_insert_sibling_node(), and mlview_xml_document_paste_node_as_sibling().

xmlNode* mlview_xml_document_insert_prev_sibling_node MlViewXMLDocument   a_xml_document,
xmlNode *    a_sibling_node,
xmlNode *    a_xml_node,
gboolean    a_subtree_required
 

Inserts a_sibling_node as the previous sibling node of a_xml_node.

Parameters:
a_xml_node  the current reference node. Must be not NULL.
a_xml_document  the current xml document. Must be not NULL.
a_sibling_node  a the new sibling node to insert. Must be not NULL.
Returns:
the newly insterted sibling (a_sibling_node) or NULL if something BAD happened.

Definition at line 878 of file mlview-xml-document.c.

References DOCUMENT_CHANGED, mlview_app_context_get_settings_value(), mlview_app_context_settings_exist(), MLVIEW_IS_XML_DOCUMENT, mlview_parsing_utils_build_required_attributes_list(), mlview_parsing_utils_build_required_children_tree(), MLVIEW_PARSING_UTILS_STATUS, PREV_SIBLING_NODE_INSERTED, and PRIVATE.

Referenced by mlview_tree_editor_insert_sibling_node(), and mlview_xml_document_paste_node_as_sibling().

gboolean mlview_xml_document_needs_saving MlViewXMLDocument   a_doc
 

Parameters:
a_doc  the current instance of MlViewXMLDocument.
Returns:
FALSE. So, please, make sure

Definition at line 1036 of file mlview-xml-document.c.

References mlview_file_descriptor_is_modified(), mlview_xml_document_get_file_descriptor(), and PRIVATE.

Referenced by mlview_editor_close_xml_document_interactive().

MlViewXMLDocument* mlview_xml_document_new xmlDocPtr    a_xml_doc,
MlViewAppContext   a_context
 

Parameters:
a_file_path  the file path of the xml document. Must be NULL terminated string. If NULL, the internal file_path is set to NULL. if NOT NULL, the string is duplicated. so that the caller can free it.

Definition at line 307 of file mlview-xml-document.c.

References MLVIEW_TYPE_XML_DOCUMENT, and PRIVATE.

Referenced by mlview_editor_create_new_xml_document(), mlview_editor_edit_xml_document(), and mlview_xml_document_open().

MlViewXMLDocument* mlview_xml_document_open gchar *    a_file_name,
MlViewAppContext   a_context
 

Opens the xml file contains in the filename given in parameter.

Parameters:
a_file_name  the total file path of the file that contains the xml document to open
a_mlview_xml_doc  the current instance of MlViewXMLDocument.

Definition at line 429 of file mlview-xml-document.c.

References mlview_parsing_utils_load_xml_file(), mlview_xml_document_new(), and mlview_xml_document_set_file_path().

Referenced by mlview_editor_load_xml_file(), and mlview_xml_document_clone().

void mlview_xml_document_paste_node_as_child MlViewXMLDocument   a_xml_document,
xmlNode *    a_parent_node
 

Definition at line 985 of file mlview-xml-document.c.

References MLVIEW_IS_XML_DOCUMENT, mlview_xml_document_add_child_node(), mlview_xml_document_get_node_from_clipboard(), and PRIVATE.

Referenced by mlview_tree_editor_paste_node_as_child().

void mlview_xml_document_paste_node_as_sibling MlViewXMLDocument   a_xml_document,
xmlNode *    a_parent_node,
xmlNode *    a_sibling_node,
gboolean    a_previous
 

Definition at line 1004 of file mlview-xml-document.c.

References MLVIEW_IS_XML_DOCUMENT, mlview_xml_document_get_node_from_clipboard(), mlview_xml_document_insert_next_sibling_node(), mlview_xml_document_insert_prev_sibling_node(), and PRIVATE.

Referenced by mlview_tree_editor_paste_node_as_sibling().

gint mlview_xml_document_save MlViewXMLDocument   a_doc
 

Parameters:
a_doc  the current instance of MlViewXMLDocument
Returns:
the number of bytes saved or -1 in case of error.

Definition at line 588 of file mlview-xml-document.c.

References mlview_file_descriptor_get_file_path(), mlview_parsing_utils_save_xml_doc(), mlview_xml_document_get_file_descriptor(), and PRIVATE.

Referenced by mlview_editor_save_xml_document(), and mlview_xml_document_save_as().

gint mlview_xml_document_save_as MlViewXMLDocument   a_doc,
gchar *    a_file_path
 

Parameters:
a_file_path 
a_doc 
Returns:
the number of bytes saved or -1 in case of error.

Definition at line 619 of file mlview-xml-document.c.

References mlview_xml_document_get_file_path(), mlview_xml_document_save(), and mlview_xml_document_set_file_path().

Referenced by mlview_editor_save_and_close_xml_document(), and mlview_editor_save_xml_document_as().

void mlview_xml_document_set_app_context MlViewXMLDocument   a_doc,
MlViewAppContext   a_context
 

Parameters:
a_doc  the current xml document.
a_context  the current application context to set to this component.

Definition at line 337 of file mlview-xml-document.c.

References MLVIEW_IS_APP_CONTEXT, and PRIVATE.

void mlview_xml_document_set_file_descriptor MlViewXMLDocument   a_xml_doc,
MlViewFileDescriptor   a_file_desc
 

Parameters:
a_xml_doc 
a_file_desc 

Definition at line 1109 of file mlview-xml-document.c.

References PRIVATE.

void mlview_xml_document_set_file_path MlViewXMLDocument   a_xml_doc,
gchar *    a_file_path
 

Parameters:
a_xml_doc 
a_file_path 

Definition at line 668 of file mlview-xml-document.c.

References FILE_PATH_CHANGED, mlview_file_descriptor_new(), mlview_file_descriptor_set_file_path(), and PRIVATE.

Referenced by mlview_xml_document_open(), and mlview_xml_document_save_as().

xmlNode * mlview_xml_document_set_node_content MlViewXMLDocument   a_xml_document,
xmlNode *    a_node,
gchar *    a_content
 

Sets a new content a_content to a_node.

Parameters:
a_content  the new content to set to a_node.
a_xml_document  the current xml document.
a_node  the node to set the new content to.
Returns:
the a_node with the new content or NULL if something bad happened.

Definition at line 814 of file mlview-xml-document.c.

References CONTENT_CHANGED, DOCUMENT_CHANGED, MLVIEW_IS_XML_DOCUMENT, and NODE_CHANGED.

xmlNode* mlview_xml_document_set_node_name MlViewXMLDocument   a_xml_document,
xmlNode *    a_node,
gchar *    a_name
 

Sets the name of a_node to a_name.

Parameters:
a_xml_document  the current xml document.
a_name  the new name to set.
a_node  the node to set the name on.
Returns:
a_node with it new name or NULL if something bad happened.

Definition at line 846 of file mlview-xml-document.c.

References DOCUMENT_CHANGED, MLVIEW_IS_XML_DOCUMENT, NAME_CHANGED, and NODE_CHANGED.

void mlview_xml_document_set_xml_document MlViewXMLDocument   a_doc,
xmlDocPtr    a_mem_doc
 

Parameters:
a_mem_doc 
a_doc 

Definition at line 1141 of file mlview-xml-document.c.

References PRIVATE.

gint mlview_xml_document_validate MlViewXMLDocument   a_doc
 

Validates the document agains the dtd that is associated to it.

Parameters:
a_doc  the document to validate.

Definition at line 552 of file mlview-xml-document.c.

References mlview_app_context_message(), mlview_app_context_warning(), mlview_parsing_utils_validate_dtd(), and PRIVATE.

Referenced by mlview_editor_validate().


Generated on Sat Jul 6 09:57:41 2002 for Gnome-MlView by doxygen1.2.16