From 46085f932749ac3d89f487c48b3322cfafd0028f Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Sun, 16 May 2004 05:25:38 +0000
Subject: [PATCH] Index and entity callback support.
---
CHANGES | 8 +-
Makefile.in | 8 +-
TODO | 11 +-
doc/reference.html | 208 ++++++++++++++++++++++++
mxml-entity.c | 97 +++++++++++-
mxml-index.c | 387 +++++++++++++++++++++++++++++++++++++++++++++
mxml.h | 23 ++-
mxml.xml | 115 ++++++++++++++
8 files changed, 835 insertions(+), 22 deletions(-)
create mode 100644 mxml-index.c
diff --git a/CHANGES b/CHANGES
index 52cadb2..06e1adf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,9 +1,15 @@
-README - 05/02/2004
+README - 05/16/2004
-------------------
CHANGES IN Mini-XML 2.0
- New programmers manual.
+ - Added index functions to build a searchable index of
+ XML nodes.
+ - Added character entity callback interface to support
+ additional character entities beyond those defined in
+ the XHTML specification.
+ - Added support for XHTML character entities.
- The mxmldoc utility now produces XML output which
conforms to an updated XML schema, described in the file
"doc/mxmldoc.xsd".
diff --git a/Makefile.in b/Makefile.in
index 7cba763..711734e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,5 +1,5 @@
#
-# "$Id: Makefile.in,v 1.20 2004/05/02 22:02:36 mike Exp $"
+# "$Id: Makefile.in,v 1.21 2004/05/16 05:25:38 mike Exp $"
#
# Makefile for Mini-XML, a small XML-like file parsing library.
#
@@ -76,8 +76,8 @@ MAN3EXT = @MAN3EXT@
DOCFILES = doc/mxml.html doc/mxml.pdf doc/mxmldoc.xsd \
README COPYING CHANGES
-PUBLIBOBJS = mxml-attr.o mxml-entity.o mxml-file.o mxml-node.o \
- mxml-search.o mxml-set.o
+PUBLIBOBJS = mxml-attr.o mxml-entity.o mxml-file.o mxml-index.o \
+ mxml-node.o mxml-search.o mxml-set.o
LIBOBJS = $(PUBLIBOBJS) mxml-private.o mxml-string.o
OBJS = mxmldoc.o testmxml.o $(LIBOBJS)
TARGETS = libmxml.a mxmldoc doc/mxml.$(CAT3EXT) \
@@ -257,5 +257,5 @@ $(OBJS): Makefile config.h
#
-# End of "$Id: Makefile.in,v 1.20 2004/05/02 22:02:36 mike Exp $".
+# End of "$Id: Makefile.in,v 1.21 2004/05/16 05:25:38 mike Exp $".
#
diff --git a/TODO b/TODO
index 6852006..05af08e 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-TODO - 05/02/2004
+TODO - 05/16/2004
-----------------
- UTF-16 support.
@@ -9,12 +9,6 @@ TODO - 05/02/2004
-- Use HTMLDOC to generate
-- Provide more tutorials
-- Release notes
- - Add indexing support.
- -- Build static index of nodes based on element and/or attribute
- (i.e. index elements, index attributes, or index attributes of
- a specific element)
- -- Provide functions to create, destroy, find first, and find next
- -- Provide additional index for first character?
- Add access methods and make node structure opaque.
-- To allow for C++ migration
-- To make future binary compatibility easier
@@ -24,6 +18,3 @@ TODO - 05/02/2004
-- Make this the core implementation which the C API accesses?
-- Class would allow for subclassing, is that necessary?
- Binary XML support???
- - Character entity support
- -- Add support for a callback which returns a Unicode
- char from an entity name.
diff --git a/doc/reference.html b/doc/reference.html
index 762d43b..c5a9c88 100644
--- a/doc/reference.html
+++ b/doc/reference.html
@@ -17,6 +17,7 @@
Structures
Types
Unions
+ Variables
@@ -45,9 +46,16 @@
mxmlDelete()
mxmlElementGetAttr()
mxmlElementSetAttr()
+ mxmlEntityAddCallback()
mxmlEntityGetName()
mxmlEntityGetValue()
+ mxmlEntityRemoveCallback()
mxmlFindElement()
+ mxmlIndexDelete()
+ mxmlIndexEnum()
+ mxmlIndexFind()
+ mxmlIndexNew()
+ mxmlIndexReset()
mxmlLoadFile()
mxmlLoadString()
mxmlNewElement()
@@ -177,6 +185,25 @@ mxmlElementSetAttr(
Returns
Nothing.
+
+
+Description
+Add a callback to convert entities to Unicode.
+Syntax
+
+void
+mxmlEntityAddCallback(
+ int (*cb)(const char *name));
+
+Arguments
+
+Name | Description |
+
+(*cb)(const char *name) | Callback function to add |
+
+Returns
+Nothing.
+
Description
@@ -220,6 +247,25 @@ mxmlEntityGetValue(
Returns
Character value or -1 on error
+
+
+Description
+Remove a callback.
+Syntax
+
+void
+mxmlEntityRemoveCallback(
+ int (*cb)(const char *name));
+
+Arguments
+
+Name | Description |
+
+(*cb)(const char *name) | Callback function to remove |
+
+Returns
+Nothing.
+
Description
@@ -258,6 +304,109 @@ mxmlFindElement(
Returns
Element node or NULL
+
+
+Description
+Sort attribute...
+Syntax
+
+void
+mxmlIndexDelete(
+ mxml_index_t * ind);
+
+Arguments
+
+Name | Description |
+
+ind | Index to delete |
+
+Returns
+Nothing.
+
+
+
+Description
+Return the next node in the index.
+Syntax
+
+mxml_node_t *
+mxmlIndexEnum(
+ mxml_index_t * ind);
+
+Arguments
+
+Name | Description |
+
+ind | Index to enumerate |
+
+Returns
+Next node or NULL if there is none
+
+
+
+Description
+Find the next matching node.
+Syntax
+
+mxml_node_t *
+mxmlIndexFind(
+ mxml_index_t * ind,
+ const char * element,
+ const char * value);
+
+Arguments
+
+Name | Description |
+
+ind | Index to search |
+element | Element name to find, if any |
+value | Attribute value, if any |
+
+Returns
+Node or NULL if none found
+
+
+
+Description
+Create a new index.
+Syntax
+
+mxml_index_t *
+mxmlIndexNew(
+ mxml_node_t * node,
+ const char * element,
+ const char * attr);
+
+Arguments
+
+Name | Description |
+
+node | XML node tree |
+element | Element to index or NULL for all |
+attr | Attribute to index or NULL for none |
+
+Returns
+New index
+
+
+
+Description
+Return the first node in the index.
+Syntax
+
+mxml_node_t *
+mxmlIndexReset(
+ mxml_index_t * ind);
+
+Arguments
+
+Name | Description |
+
+ind | Index to reset |
+
+Returns
+First node or NULL if there is none
+
Description
@@ -814,6 +963,7 @@ mxmlWalkPrev(
+struct mxml_index_s
+{
+ int alloc_nodes;
+ char * attr;
+ int cur_node;
+ mxml_node_t ** nodes;
+ int num_nodes;
+};
+
+Members
+
+Name | Description |
+
+alloc_nodes | Allocated nodes in index |
+attr | Attribute used for indexing or NULL |
+cur_node | Current node |
+nodes | Node array |
+num_nodes | Number of nodes in index |
+
+
Description
@@ -915,6 +1091,7 @@ struct mxml_value_s
+typedef struct mxml_index_s mxml_index_t;
+
+
Description
@@ -1005,5 +1191,27 @@ union mxml_value_u
real | Real number |
text | Text fragment |
+
+
+
+
+
+
+Definition
+
+static int num_callbacks = 1;
+
+
+
+
+Description
+Delete an index.
+Definition
+
+static const char * sort_attr_name;
+