From f6de672b866b65db43cf23cf914e54c72210891e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 9 Jun 2003 12:28:06 +0000 Subject: [PATCH] added new method and type to add namespaces to xml files. No actual code is implemented yet. Original commit message from CVS: added new method and type to add namespaces to xml files. No actual code is implemented yet. --- gst/gstxml.c | 40 +++++++++++++++++++++++++++++++++++----- gst/gstxml.h | 9 +++++++++ 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/gst/gstxml.c b/gst/gstxml.c index 0e9384dff0..6f50c5ba67 100644 --- a/gst/gstxml.c +++ b/gst/gstxml.c @@ -107,25 +107,39 @@ gst_xml_new (void) * Returns: a pointer to an XML document */ xmlDocPtr -gst_xml_write (GstElement *element) +gst_xml_write_ns (GstElement *element, gint num_ns, GstXMLNs ns[]) { xmlDocPtr doc; xmlNodePtr elementnode; - xmlNsPtr ns; + xmlNsPtr gst_ns; doc = xmlNewDoc ("1.0"); doc->xmlRootNode = xmlNewDocNode (doc, NULL, "gstreamer", NULL); - ns = xmlNewNs (doc->xmlRootNode, "http://gstreamer.net/gst-core/1.0/", "gst"); + gst_ns = xmlNewNs (doc->xmlRootNode, "http://gstreamer.net/gst-core/1.0/", "gst"); - elementnode = xmlNewChild (doc->xmlRootNode, ns, "element", NULL); + elementnode = xmlNewChild (doc->xmlRootNode, gst_ns, "element", NULL); gst_object_save_thyself (GST_OBJECT (element), elementnode); return doc; } +/** + * gst_xml_write: + * @element: The element to write out + * + * Converts the given element into an XML presentation. + * + * Returns: a pointer to an XML document + */ +xmlDocPtr +gst_xml_write (GstElement *element) +{ + return gst_xml_write_ns (element, 0, NULL); +} + /** * gst_xml_write_file: * @element: The element to write out @@ -137,7 +151,7 @@ gst_xml_write (GstElement *element) * Returns: number of bytes written on success, -1 otherwise. */ gint -gst_xml_write_file (GstElement *element, FILE *out) +gst_xml_write_file_ns (GstElement *element, FILE *out, gint num_ns, GstXMLNs ns[]) { xmlDocPtr cur; #ifdef HAVE_LIBXML2 @@ -188,6 +202,22 @@ gst_xml_write_file (GstElement *element, FILE *out) return ret; } +/** + * gst_xml_write_file: + * @element: The element to write out + * @out: an open file, like stdout + * + * Converts the given element into XML and writes the formatted XML to an open + * file. + * + * Returns: number of bytes written on success, -1 otherwise. + */ +gint +gst_xml_write_file (GstElement *element, FILE *out) +{ + return gst_xml_write_file_ns (element, out, 0, NULL); +} + /** * gst_xml_parse_doc: * @xml: a pointer to a GstXML object diff --git a/gst/gstxml.h b/gst/gstxml.h index 651cb79257..352da43130 100644 --- a/gst/gstxml.h +++ b/gst/gstxml.h @@ -50,6 +50,13 @@ struct _GstXML { xmlNsPtr ns; }; +typedef struct _GstXMLNs GstXMLNs; + +struct _GstXMLNs { + gchar *href; + gchar *prefix; +}; + struct _GstXMLClass { GstObjectClass parent_class; @@ -63,9 +70,11 @@ GType gst_xml_get_type (void); /* create an XML document out of a pipeline */ xmlDocPtr gst_xml_write (GstElement *element); +xmlDocPtr gst_xml_write_ns (GstElement *element, gint num_ns, GstXMLNs ns[]); /* write a formatted representation of a pipeline to an open file */ gint gst_xml_write_file (GstElement *element, FILE *out); +gint gst_xml_write_file_ns (GstElement *element, FILE *out, gint num_ns, GstXMLNs ns[]); GstXML* gst_xml_new (void);