diff --git a/www/docfiles/advanced.html b/www/docfiles/advanced.html index 8cf2a90..1796695 100644 --- a/www/docfiles/advanced.html +++ b/www/docfiles/advanced.html @@ -1,9 +1,9 @@
-The save callback receives the node pointer and returns an allocated string containing the custom data value. The following save callback could be used for our ISO date/time type:
@@ -317,7 +318,7 @@ MXML_WS_BEFORE_CLOSE, or MXML_WS_AFTER_CLOSE. The callback iso_date_time_t *dt; - dt = (iso_date_time_t *)node->custom.data; + dt = (iso_date_time_t *)mxmlGetCustom(node); snprintf(data, sizeof(data), "%04u-%02u-%02uT%02u:%02u:%02uZ", @@ -512,7 +513,7 @@ mxmlIndexEnum. * Retain headings and titles... */ - char *name = node->value.element.name; + char *name = mxmlGetElement(node); if (!strcmp(name, "html") || !strcmp(name, "head") || @@ -528,15 +529,17 @@ mxmlIndexEnum. } else if (event == MXML_SAX_DIRECTIVE) mxmlRetain(node); - else if (event == MXML_SAX_DATA && - node->parent->ref_count > 1) + else if (event == MXML_SAX_DATA) { - /* - * If the parent was retained, then retain - * this data node as well. - */ + if (mxmlGetRefCount(mxmlGetParent(node)) > 1) + { + /* + * If the parent was retained, then retain + * this data node as well. + */ - mxmlRetain(node); + mxmlRetain(node); + } } } @@ -564,9 +567,9 @@ mxmlIndexEnum. if (body) { - for (heading = body->child; + for (heading = mxmlGetFirstChild(body); heading; - heading = heading->next) + heading = mxmlGetNextSibling(heading)) print_children(heading); } diff --git a/www/docfiles/basics.html b/www/docfiles/basics.html index aa0f976..c3e3521 100644 --- a/www/docfiles/basics.html +++ b/www/docfiles/basics.html @@ -1,9 +1,9 @@ -Every piece of information in an XML file (elements, text, numbers) - is stored in memory in "nodes". Nodes are defined by the -mxml_node_t structure. The -type member defines the node type (element, integer, - opaque, real, or text) which determines which value you want to look at - in the value union.
- - -Value | Type | Node member |
---|---|---|
Custom | void * | -node->value.custom.data |
Element | char * | -node->value.element.name |
Integer | int | node->value.integer - |
Opaque (string) | char * | -node->value.opaque |
Real | double | node->value.real | -
Text | char * | node->value.text.string - |
Each node also has a user_data member which allows you to - associate application-specific data with each node as needed.
-New nodes are created using the -mxmlNewElement, -mxmlNewInteger, -mxmlNewOpaque, -mxmlNewReal, -mxmlNewText -mxmlNewTextf mxmlNewXML - functions. Only elements can have child nodes, and the top node - must be an element, usually the <?xml version="1.0"?> node - created by mxmlNewXML().
-Nodes have pointers to the node above (parent), below ( -child), left (prev), and right (next) of the - current node. If you have an XML file like the following:
+Every piece of information in an XML file is stored in memory in + "nodes". Nodes are defined by the +mxml_node_t structure. Each node has a typed value, optional + user data, a parent node, sibling nodes (previous and next), and + potentially child nodes.
+For example, if you have an XML file like the following:
- <?xml version="1.0"?> + <?xml version="1.0" encoding="utf-8"?> <data> <node>val1</node> <node>val2</node> @@ -125,7 +89,7 @@ child), left (prev), and right (next) of the
the node tree for the file would look like the following in memory:
- ?xml + ?xml version="1.0" encoding="utf-8"? | data | @@ -137,15 +101,100 @@ child), left (prev), and right (next) of the | | | val4 val5 val6-
where "-" is a pointer to the next node and "|" is a pointer to the - first child node.
-Once you are done with the XML data, use the -mxmlDelete function to recursively free the memory that is - used for a particular node or the entire tree:
-- mxmlDelete(tree); -+
where "-" is a pointer to the sibling node and "|" is a pointer to + the first child or parent node.
+The mxmlGetType + function gets the type of a node, one of MXML_CUSTOM, +MXML_ELEMENT, MXML_INTEGER, MXML_OPAQUE, +MXML_REAL, or MXML_TEXT. The parent and sibling nodes are + accessed using the +mxmlGetParent, mxmlGetNext, + and mxmlGetPrevious functions. + The mxmlGetUserData + function gets any user data associated with the node.
+CDATA (MXML_ELEMENT) nodes are created using the +mxmlNewCDATA function. The +mxmlGetCDATA function retrieves the CDATA string pointer + for a node.
+Note: ++CDATA nodes are currently stored in memory as special elements. This + will be changed in a future major release of Mini-XML.
+
Custom (MXML_CUSTOM) nodes are created using the +mxmlNewCustom function or using a custom load callback + specified using the +mxmlSetCustomHandlers function. The +mxmlGetCustom function retrieves the custom value pointer + for a node.
+Comment (MXML_ELEMENT) nodes are created using the +mxmlNewElement function. The +mxmlGetElement function retrieves the comment string + pointer for a node, including the surrounding "!--" and "--" + characters.
+Note: ++Comment nodes are currently stored in memory as special elements. + This will be changed in a future major release of Mini-XML.
+
Element (MXML_ELEMENT) nodes are created using the +mxmlNewElement function. The +mxmlGetElement function retrieves the element name, the +mxmlElementGetAttr function retrieves the value string for + a named attribute associated with the element, and the +mxmlGetFirstChild and +mxmlGetLastChild functions retrieve the first and last + child nodes for the element, respectively.
+Integer (MXML_INTEGER) nodes are created using the +mxmlNewInteger function. The +mxmlGetInteger function retrieves the integer value for a + node.
+Opaque (MXML_OPAQUE) nodes are created using the +mxmlNewOpaque function. The +mxmlGetOpaque function retrieves the opaque string pointer + for a node. Opaque nodes are like string nodes but preserve all + whitespace between nodes.
+Text (MXML_TEXT) nodes are created using the +mxmlNewText and +mxmlNewTextf functions. Each text node consists of a text + string and (leading) whitespace value - the +mxmlGetText function retrieves the text string pointer and + whitespace value for a node.
+ + +Processing instruction (MXML_ELEMENT) nodes are created + using the mxmlNewElement + function. The +mxmlGetElement function retrieves the processing instruction + string for a node, including the surrounding "?" characters.
+Note: ++Processing instruction nodes are currently stored in memory as + special elements. This will be changed in a future major release of + Mini-XML.
+
Real number (MXML_REAL) nodes are created using the +mxmlNewReal function. The +mxmlGetReal function retrieves the CDATA string pointer for + a node.
+ +XML declaration (MXML_ELEMENT) nodes are created using the mxmlNewXML function. The mxmlGetElement + function retrieves the XML declaration string for a node, including the + surrounding "?" characters.
+Note: +XML declaration nodes are currently stored in memory as special + elements. This will be changed in a future major release of Mini-XML.
+
You can create and update XML documents in memory using the various @@ -182,9 +231,11 @@ mxmlNew functions. The following code will create the XML document node = mxmlNewElement(data, "node"); mxmlNewText(node, 0, "val8"); -
We start by creating the <?xml version="1.0"?> node common - to all XML files using the -mxmlNewXML function:
+ + +We start by creating the declaration node common to all XML files + using the mxmlNewXML + function:
xml = mxmlNewXML("1.0");@@ -208,7 +259,7 @@ mxmlNewText functions. The first argument of mxmlNewText
The resulting in-memory XML document can then be saved or processed just like one loaded from disk or a string.
- +You load an XML file using the mxmlLoadFile function:
@@ -256,7 +307,7 @@ mxmlLoadFile(). The second argument specifies the string or character buffer to load and must be a complete XML document including the ?xml element if the parent node is NULL. - +You save an XML file using the mxmlSaveFile function:
@@ -297,6 +348,8 @@ mxmlSaveFile(). The mxmlSaveString function takes pointer and size arguments for saving the XML document to a fixed-size buffer, while mxmlSaveAllocString() returns a string buffer that was allocated using malloc(). + +When saving XML documents, Mini-XML normally wraps output lines at
column 75 so that the text is readable in terminal windows. The
@@ -309,9 +362,23 @@ mxmlSaveFile(). The mxmlSaveString function takes pointer
/* Disable wrapping */
mxmlSetWrapMargin(0);
+ Once you are done with the XML data, use the
+mxmlDelete function to recursively free the memory that is
+ used for a particular node or the entire tree: You can also use reference counting to manage memory usage. The
+mxmlRetain and
+mxmlRelease functions increment and decrement a node's use
+ count, respectively. When the use count goes to 0, mxmlRelease
+ will automatically call mxmlDelete to actually free the memory
+ used by the node tree. New nodes automatically start with a use count
+ of 1. The mxmlWalkPrev
and mxmlWalkNext
functions can be used to iterate through the XML node tree:Memory Management
+
+ mxmlDelete(tree);
+
+Finding and Iterating Nodes
+Finding and Iterating Nodes
You can find specific nodes in the tree using the +mxmlFindPath, for example:
++ mxml_node_t *value; + + value = mxmlFindPath(tree, "path/to/*/foo/bar"); ++
The second argument is a "path" to the parent node. Each component of + the path is separated by a slash (/) and represents a named element in + the document tree or a wildcard (*) path representing 0 or more + intervening nodes.
- http://www.easysw.com/epm/ + http://www.epmhome.org/
Use the make command with the epm target to create portable and native packages for your system:
diff --git a/www/docfiles/intro.html b/www/docfiles/intro.html index a984d66..865c6b8 100644 --- a/www/docfiles/intro.html +++ b/www/docfiles/intro.html @@ -1,9 +1,9 @@ -This programmers manual describes Mini-XML version 2.6, a small XML +
This programmers manual describes Mini-XML version 2.7, a small XML parsing library that you can use to read and write XML data files in your C and C++ applications.
Mini-XML was initially developed for the @@ -48,12 +48,12 @@ libxml2 library with something substantially smaller and libxml2.
Thanks to lots of feedback and support from various developers, Mini-XML has evolved since then to provide a more complete XML - implementation and now stands at a whopping 3,441 lines of code, + implementation and now stands at a whopping 3,965 lines of code, compared to 103,893 lines of code for libxml2 version 2.6.9.
Aside from Gutenprint, Mini-XML is used for the following projects/software applications:
Please email me (mxml @ easysw . com) if you would like your project @@ -165,7 +165,7 @@ libxml2 library with something substantially smaller and
The Mini-XML library is copyright 2003-2009 by Michael Sweet. License +
The Mini-XML library is copyright 2003-2011 by Michael Sweet. License terms are described in Appendix A - Mini-XML License.
The Mini-XML library and included programs are provided under the - terms of the GNU Library General Public License (LGPL) with the - following exceptions:
-1. Static linking of applications to the Mini-XML library does + not constitute a derivative work and does not require the author to + provide source code for the application, use the shared Mini-XML + libraries, or link their applications against a user-supplied version + of Mini-XML.
If you link the application to a modified version of Mini-XML, then the changes to Mini-XML must be provided under the terms of the - LGPL in sections 1, 2, and 4.
-2. You do not have to provide a copy of the Mini-XML license + with programs that are linked to the Mini-XML library, nor do you have + to identify the Mini-XML license in your program or documentation as + required by section 6 of the LGPL2.
+
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
diff --git a/www/docfiles/mxmldoc.html b/www/docfiles/mxmldoc.html
index 3683ad2..a799343 100644
--- a/www/docfiles/mxmldoc.html
+++ b/www/docfiles/mxmldoc.html
@@ -1,9 +1,9 @@
Comments appearing directly before a function or type definition are used to document that function or type. Comments appearing after argument, definition, return type, or variable declarations are used to @@ -144,8 +144,8 @@ hspace="10" src="4.gif" width="100">Using the mxmldoc Utility included in the documentation
Find a node with the given path.
+ mxml_node_t *mxmlFindPath (
+
mxml_node_t *top,
+
const char *path
+
);
Found node or NULL
+The "path" is a slash-separated list of element
+ names. The name "*" is considered a wildcard for one or more levels of
+ elements. For example, "foo/one/two", "bar/two/one", "*/one", and so
+ forth.
+
+
The first child node of the found node is returned if the given
+ node has children and the first child is a value node.
Get the value for a CDATA node.
+ const char *mxmlGetCDATA (
+
mxml_node_t *node
+
);
CDATA value or NULL
+NULL
is returned if the node is not a
+ CDATA element.
Get the value for a custom node.
+ const void *mxmlGetCustom (
+
mxml_node_t *node
+
);
Custom value or NULL
+NULL
is returned if the node (or its
+ first child) is not a custom value node.
Get the name for an element node.
+ const char *mxmlGetElement (
+
mxml_node_t *node
+
);
Element name or NULL
+NULL
is returned if the node is not
+ an element node.
Get the first child of an element node.
+ mxml_node_t
+ *mxmlGetFirstChild (
+
mxml_node_t *node
+
);
First child or NULL
+NULL
is returned if the node is not
+ an element node or if the node has no children.
Get the integer value from the specified node or + its first child.
+ int mxmlGetInteger (
+
mxml_node_t *node
+
);
Integer value or 0
+0 is returned if the node (or its first child) is + not an integer value node.
+Get the last child of an element node.
+ mxml_node_t
+ *mxmlGetLastChild (
+
mxml_node_t *node
+
);
Last child or NULL
+NULL
is returned if the node is not
+ an element node or if the node has no children.
Return the node type...
+ mxml_node_t
+ *mxmlGetNextSibling (
+
mxml_node_t *node
+
);
Get the next node for the current parent.
+NULL
is returned if this is the last
+ child for the current parent.
Get an opaque string value for a node or its + first child.
+ const char *mxmlGetOpaque (
+
mxml_node_t *node
+
);
Opaque string or NULL
+NULL
is returned if the node (or its
+ first child) is not an opaque value node.
Get the parent node.
+ mxml_node_t *mxmlGetParent (
+
mxml_node_t *node
+
);
Parent node or NULL
+NULL
is returned for a root node.
Get the previous node for the current parent.
+ mxml_node_t
+ *mxmlGetPrevSibling (
+
mxml_node_t *node
+
);
Previous node or NULL
+NULL
is returned if this is the first
+ child for the current parent.
Get the real value for a node or its first child.
+ double mxmlGetReal (
+
mxml_node_t *node
+
);
Real value or 0.0
+0.0 is returned if the node (or its first child) + is not a real value node.
+Get the current reference (use) count for a node.
+ int mxmlGetRefCount (
+
mxml_node_t *node
+
);
Reference count
+The initial reference count of new nodes is 1. Use
+ the mxmlRetain
and
+mxmlRelease
functions to increment and decrement a
+ node's reference count. .
Get the text value for a node or its first child.
+ const char *mxmlGetText (
+
mxml_node_t *node,
+
int *whitespace
+
);
Text string or NULL
+NULL
is returned if the node (or its
+ first child) is not a text node. The "whitespace" argument can be NULL.
Get the node type.
+ mxml_type_t mxmlGetType (
+
mxml_node_t *node
+
);
Type of node
+MXML_IGNORE
is returned if "node" is
+NULL
.
Get the user data pointer for a node.
+ void *mxmlGetUserData (
+
mxml_node_t *node
+
);
User data pointer
Delete an index.
void mxmlIndexDelete ( @@ -458,6 +752,20 @@ mxmlEntityRemoveCallback this function for the first time with a particular set of "element" and "value" strings. Passing NULL for both "element" and "value" is equivalent to calling mxmlIndexEnum().
+Get the number of nodes in an index.
+ int mxmlIndexGetCount (
+
mxml_index_t *ind
+
);
Number of nodes in index
Create a new index.
mxml_index_t *mxmlIndexNew
@@ -588,7 +896,7 @@ mxmlEntityRemoveCallback
The constants MXML_INTEGER_CALLBACK, MXML_OPAQUE_CALLBACK,
MXML_REAL_CALLBACK, and MXML_TEXT_CALLBACK are defined for loading
child nodes of the specified type.
Create a new CDATA node.
@@ -611,7 +919,7 @@ mxmlEntityRemoveCallback to specify that the new CDATA node has no parent. The data string must be nul-terminated and is copied into the new node. CDATA nodes use the MXML_ELEMENT type. -Create a new custom data node.
@@ -770,7 +1078,7 @@ mxmlEntityRemoveCallback parameter is used to specify whether leading whitespace is present before the node. The format string must be nul-terminated and is formatted into the new node. -Create a new XML document tree.
@@ -788,7 +1096,7 @@ mxmlEntityRemoveCallbackThe "version" argument specifies the version number to put in the ?xml element node. If NULL, version 1.0 is assumed.
-Release a node.
@@ -819,7 +1127,7 @@ mxmlEntityRemoveCallbackDoes not free memory used by the node - use mxmlDelete() for that. This function does nothing if the node has no parent.
-Retain a node.
@@ -833,7 +1141,7 @@ mxmlEntityRemoveCallbackNew reference count
-Load a file descriptor into an XML node tree
@@ -875,7 +1183,7 @@ mxmlEntityRemoveCallback
The SAX callback must call mxmlRetain() for any nodes that need to
be kept for later use. Otherwise, nodes are deleted when the parent
node is closed or after each data, comment, CDATA, or directive node.
Load a file into an XML node tree using a SAX
@@ -918,7 +1226,7 @@ mxmlEntityRemoveCallback
The SAX callback must call mxmlRetain() for any nodes that need to
be kept for later use. Otherwise, nodes are deleted when the parent
node is closed or after each data, comment, CDATA, or directive node.
Load a string into an XML node tree using a SAX @@ -963,7 +1271,7 @@ mxmlEntityRemoveCallback node is closed or after each data, comment, CDATA, or directive node.
Save an XML node tree to an allocated string.
+Save an XML tree to an allocated string.
char *mxmlSaveAllocString (
mxml_node_t *node,
mxml_save_cb_t cb
@@ -1068,7 +1376,7 @@ mxmlEntityRemoveCallback
MXML_NO_CALLBACK is specified, whitespace will only be added before
MXML_TEXT nodes with leading whitespace and before attribute names
inside opening element tags.
Set the element name of a CDATA node.
@@ -1088,7 +1396,7 @@ mxmlEntityRemoveCallbackThe node is not changed if it is not a CDATA element node.
-Set the data and destructor of a custom data @@ -1261,10 +1569,27 @@ mxmlSetCustomHandlers
0 on success, -1 on failure
The node is not changed if it is not a text node.
-Set the user data pointer for a node.
+ int mxmlSetUserData (
+
mxml_node_t *node,
+
void *data
+
);
0 on success, -1 on failure
+Set the the wrap margin when saving XML data.
+Set the wrap margin when saving XML data.
void mxmlSetWrapMargin (
int column
);
An XML element attribute value.
-typedef struct mxml_attr_s - mxml_attr_t;
Custom data destructor
@@ -1340,16 +1661,6 @@ mxml_custom_save_cb_tCustom data save callback function
typedef char *(*mxml_custom_save_cb_t)( mxml_node_t *);
-An XML custom value.
-typedef struct mxml_custom_s - mxml_custom_t;
-An XML element value.
-typedef struct mxml_element_s - mxml_element_t;
Entity callback function
typedef int (*mxml_entity_cb_t)(const char *);
@@ -1380,161 +1691,10 @@ mxml_node_t *, mxml_sax_event_t, void *);SAX event type.
typedef enum mxml_sax_event_e mxml_sax_event_t;
-An XML text value.
-typedef struct mxml_text_s - mxml_text_t;
The XML node type.
typedef enum mxml_type_e mxml_type_t;
-An XML node value.
-typedef union mxml_value_u - mxml_value_t;
-An XML element attribute value.
-struct mxml_attr_s {
-
char *name;
-
char *value;
-
};
An XML custom value.
-struct mxml_custom_s {
-
void *data;
-
mxml_custom_destroy_cb_t
- destroy;
-
};
An XML element value.
-struct mxml_element_s {
-
mxml_attr_t *attrs;
-
char *name;
-
int num_attrs;
-
};
An XML node index.
-struct mxml_index_s {
-
int alloc_nodes;
-
char *attr;
-
int cur_node;
-
mxml_node_t **nodes;
-
int num_nodes;
-
};
An XML node.
-struct mxml_node_s {
-
struct mxml_node_s *child;
-
struct mxml_node_s *last_child;
-
struct mxml_node_s *next;
-
struct mxml_node_s *parent;
-
struct mxml_node_s *prev;
-
int ref_count;
-
mxml_type_t type;
-
void *user_data;
-
mxml_value_t value;
-
};
An XML text value.
-struct mxml_text_s {
-
char *string;
-
int whitespace;
-
};
An XML node value.
-union mxml_value_u {
-
mxml_custom_t custom;
-
mxml_element_t element;
-
int integer;
-
char *opaque;
-
double real;
-
mxml_text_t text;
-
};
SAX event type.
diff --git a/www/docfiles/relnotes.html b/www/docfiles/relnotes.html index 6af7afd..4d34e95 100644 --- a/www/docfiles/relnotes.html +++ b/www/docfiles/relnotes.html @@ -1,9 +1,9 @@ -This appendix provides the XML schema that is used for the XML files produced by mxmldoc. This schema is available on-line at:
- http://www.easysw.com/~mike/mxmldoc.xsd + http://www.minixml.org/mxmldoc.xsd
@@ -39,8 +39,8 @@ hspace="10" src="D.gif" width="100">XML Schema <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:annotation> <xsd:documentation xml:lang="en"> - Mini-XML 2.3 documentation schema for mxmldoc output. - Copyright 2003-2007 by Michael Sweet. + Mini-XML 2.7 documentation schema for mxmldoc output. + Copyright 2003-2011 by Michael Sweet. </xsd:documentation> </xsd:annotation> diff --git a/www/documentation.php b/www/documentation.php index 2c483f4..1323a03 100644 --- a/www/documentation.php +++ b/www/documentation.php @@ -164,7 +164,7 @@ else { // Run htmlsearch to search the documentation... $matches = array(); - $fp = popen("/home/mike/bin/htmlsearch " . escapeshellarg($q), "r"); + $fp = popen("/usr/local/bin/websearch " . escapeshellarg($q), "r"); while ($line = fgets($fp, 1024)) {