mirror of
https://github.com/michaelrsweet/mxml.git
synced 2024-11-08 13:39:58 +00:00
Add MXML_IGNORE and MXML_IGNORE_CB to allow whitespace to be
ignored in element-only XML files.
This commit is contained in:
parent
e0262e0099
commit
19b8ed648f
4
CHANGES
4
CHANGES
@ -1,8 +1,10 @@
|
||||
CHANGES - 05/30/2005
|
||||
CHANGES - 06/07/2005
|
||||
--------------------
|
||||
|
||||
CHANGES IN Mini-XML 2.2.3
|
||||
|
||||
- Added new MXML_IGNORE type and MXML_IGNORE_CB callback
|
||||
to ignore non-element nodes (i.e. whitespace)
|
||||
- mxmlLoad*() crashed when reporting an error in some
|
||||
invalid XML (STR #23)
|
||||
|
||||
|
1
configure
vendored
1
configure
vendored
@ -1,4 +1,5 @@
|
||||
#! /bin/sh
|
||||
pwd
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.57.
|
||||
#
|
||||
|
@ -34,6 +34,7 @@
|
||||
<tbody>
|
||||
<tr><td><tt>MXML_CUSTOM</tt></td><td>Custom data</td></tr>
|
||||
<tr><td><tt>MXML_ELEMENT</tt></td><td>XML element with attributes</td></tr>
|
||||
<tr><td><tt>MXML_IGNORE</tt></td><td>Ignore/throw away node</td></tr>
|
||||
<tr><td><tt>MXML_INTEGER</tt></td><td>Integer value</td></tr>
|
||||
<tr><td><tt>MXML_OPAQUE</tt></td><td>Opaque string</td></tr>
|
||||
<tr><td><tt>MXML_REAL</tt></td><td>Real value</td></tr>
|
||||
@ -450,7 +451,7 @@ child nodes of the specified type.</p>
|
||||
mxmlLoadFd(
|
||||
<a href='#mxml_node_t'>mxml_node_t</a> * top,
|
||||
int fd,
|
||||
<a href='#mxml_type_t'>mxml_type_t</a> (*cb)(mxml_node_t *node));
|
||||
mxml_type_t (*cb)(mxml_node_t *node));
|
||||
</pre>
|
||||
<h4>Arguments</h4>
|
||||
<p class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0' width='80%'>
|
||||
@ -484,7 +485,7 @@ child nodes of the specified type.</p>
|
||||
mxmlLoadFile(
|
||||
<a href='#mxml_node_t'>mxml_node_t</a> * top,
|
||||
FILE * fp,
|
||||
<a href='#mxml_type_t'>mxml_type_t</a> (*cb)(mxml_node_t *node));
|
||||
mxml_type_t (*cb)(mxml_node_t *node));
|
||||
</pre>
|
||||
<h4>Arguments</h4>
|
||||
<p class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0' width='80%'>
|
||||
@ -518,7 +519,7 @@ child nodes of the specified type.</p>
|
||||
mxmlLoadString(
|
||||
<a href='#mxml_node_t'>mxml_node_t</a> * top,
|
||||
const char * s,
|
||||
<a href='#mxml_type_t'>mxml_type_t</a> (*cb)(mxml_node_t *node));
|
||||
mxml_type_t (*cb)(mxml_node_t *node));
|
||||
</pre>
|
||||
<h4>Arguments</h4>
|
||||
<p class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0' width='80%'>
|
||||
@ -1150,7 +1151,7 @@ mxmlWalkPrev(
|
||||
<h3><a name='mxml_attr_s'>mxml_attr_s</a></h3>
|
||||
<hr noshade/>
|
||||
<h4>Description</h4>
|
||||
<p>An XML element attribute value.</p>
|
||||
<p>Data types...</p>
|
||||
<h4>Definition</h4>
|
||||
<pre>
|
||||
struct mxml_attr_s
|
||||
@ -1224,7 +1225,7 @@ struct mxml_node_s
|
||||
struct <a href='#mxml_node_s'>mxml_node_s</a> * next;
|
||||
struct <a href='#mxml_node_s'>mxml_node_s</a> * parent;
|
||||
struct <a href='#mxml_node_s'>mxml_node_s</a> * prev;
|
||||
<a href='#mxml_type_t'>mxml_type_t</a> type;
|
||||
mxml_type_t type;
|
||||
<a href='#mxml_value_t'>mxml_value_t</a> value;
|
||||
};
|
||||
</pre>
|
||||
@ -1291,14 +1292,13 @@ struct mxml_value_s
|
||||
<li><a href='#mxml_index_t'><tt>mxml_index_t</tt></a></li>
|
||||
<li><a href='#mxml_node_t'><tt>mxml_node_t</tt></a></li>
|
||||
<li><a href='#mxml_text_t'><tt>mxml_text_t</tt></a></li>
|
||||
<li><a href='#mxml_type_t'><tt>mxml_type_t</tt></a></li>
|
||||
<li><a href='#mxml_value_t'><tt>mxml_value_t</tt></a></li>
|
||||
</ul>
|
||||
<!-- NEW PAGE -->
|
||||
<h3><a name='mxml_attr_t'>mxml_attr_t</a></h3>
|
||||
<hr noshade/>
|
||||
<h4>Description</h4>
|
||||
<p>An XML element attribute value.</p>
|
||||
<p>Data types...</p>
|
||||
<h4>Definition</h4>
|
||||
<pre>
|
||||
typedef struct <a href='#mxml_attr_s'>mxml_attr_s</a> mxml_attr_t;
|
||||
@ -1349,15 +1349,6 @@ typedef struct <a href='#mxml_node_s'>mxml_node_s</a> mxml_node_t;
|
||||
typedef struct <a href='#mxml_text_s'>mxml_text_s</a> mxml_text_t;
|
||||
</pre>
|
||||
<!-- NEW PAGE -->
|
||||
<h3><a name='mxml_type_t'>mxml_type_t</a></h3>
|
||||
<hr noshade/>
|
||||
<h4>Description</h4>
|
||||
<p>The XML node type.</p>
|
||||
<h4>Definition</h4>
|
||||
<pre>
|
||||
typedef enum <a href='#mxml_type_e'>mxml_type_e</a> mxml_type_t;
|
||||
</pre>
|
||||
<!-- NEW PAGE -->
|
||||
<h3><a name='mxml_value_t'>mxml_value_t</a></h3>
|
||||
<hr noshade/>
|
||||
<h4>Description</h4>
|
||||
|
@ -1409,7 +1409,7 @@ mxml_load_data(mxml_node_t *top, /* I - Top node */
|
||||
break;
|
||||
}
|
||||
|
||||
default : /* Should never happen... */
|
||||
default : /* Ignore... */
|
||||
node = NULL;
|
||||
break;
|
||||
}
|
||||
@ -1429,7 +1429,7 @@ mxml_load_data(mxml_node_t *top, /* I - Top node */
|
||||
bufptr = buffer;
|
||||
whitespace = isspace(ch) && type == MXML_TEXT;
|
||||
|
||||
if (!node)
|
||||
if (!node && type != MXML_IGNORE)
|
||||
{
|
||||
/*
|
||||
* Print error and return...
|
||||
@ -1440,7 +1440,7 @@ mxml_load_data(mxml_node_t *top, /* I - Top node */
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!first)
|
||||
if (!first && node)
|
||||
first = node;
|
||||
}
|
||||
else if (isspace(ch) && type == MXML_TEXT)
|
||||
|
@ -261,6 +261,8 @@ mxmlDelete(mxml_node_t *node) /* I - Node to delete */
|
||||
node->value.custom.destroy)
|
||||
(*(node->value.custom.destroy))(node->value.custom.data);
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -84,6 +84,19 @@ mxml_error(const char *format, /* I - Printf-style format string */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'mxml_ignore_cb()' - Default callback for ignored values.
|
||||
*/
|
||||
|
||||
mxml_type_t /* O - Node type */
|
||||
mxml_ignore_cb(mxml_node_t *node) /* I - Current node */
|
||||
{
|
||||
(void)node;
|
||||
|
||||
return (MXML_IGNORE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'mxml_integer_cb()' - Default callback for integer values.
|
||||
*/
|
||||
|
3
mxml.h
3
mxml.h
@ -49,6 +49,8 @@
|
||||
# define MXML_REAL_CALLBACK mxml_real_cb
|
||||
/* Treat all data as real numbers */
|
||||
# define MXML_TEXT_CALLBACK 0 /* Treat all data as text */
|
||||
# define MXML_IGNORE_CALLBACK mxml_ignore_cb
|
||||
/* Ignore all non-element content */
|
||||
|
||||
# define MXML_NO_PARENT 0 /* No parent for the node */
|
||||
|
||||
@ -72,6 +74,7 @@
|
||||
|
||||
typedef enum mxml_type_e /**** The XML node type. ****/
|
||||
{
|
||||
MXML_IGNORE = -1, /* Ignore/throw away node */
|
||||
MXML_ELEMENT, /* XML element with attributes */
|
||||
MXML_INTEGER, /* Integer value */
|
||||
MXML_OPAQUE, /* Opaque string */
|
||||
|
11
mxml.xml
11
mxml.xml
@ -811,7 +811,7 @@ the walk to the node's children.</description>
|
||||
</argument>
|
||||
</function>
|
||||
<struct name="mxml_attr_s">
|
||||
<description>An XML element attribute value.</description>
|
||||
<description>Data types...</description>
|
||||
<variable name="name">
|
||||
<type>char *</type>
|
||||
<description>Attribute name</description>
|
||||
@ -823,7 +823,7 @@ the walk to the node's children.</description>
|
||||
</struct>
|
||||
<typedef name="mxml_attr_t">
|
||||
<type>struct mxml_attr_s</type>
|
||||
<description>An XML element attribute value.</description>
|
||||
<description>Data types...</description>
|
||||
</typedef>
|
||||
<struct name="mxml_custom_s">
|
||||
<description>An XML custom value.</description>
|
||||
@ -925,6 +925,9 @@ the walk to the node's children.</description>
|
||||
<constant name="MXML_ELEMENT">
|
||||
<description>XML element with attributes</description>
|
||||
</constant>
|
||||
<constant name="MXML_IGNORE">
|
||||
<description>Ignore/throw away node</description>
|
||||
</constant>
|
||||
<constant name="MXML_INTEGER">
|
||||
<description>Integer value</description>
|
||||
</constant>
|
||||
@ -938,10 +941,6 @@ the walk to the node's children.</description>
|
||||
<description>Text fragment</description>
|
||||
</constant>
|
||||
</enumeration>
|
||||
<typedef name="mxml_type_t">
|
||||
<type>enum mxml_type_e</type>
|
||||
<description>The XML node type.</description>
|
||||
</typedef>
|
||||
<struct name="mxml_value_s">
|
||||
<description>An XML element value.</description>
|
||||
<variable name="attrs">
|
||||
|
Loading…
Reference in New Issue
Block a user