Permalink
Browse files

adding XInclude support to the reader interface. Lot of testing of the

* xinclude.c xmlreader.c include/libxml/xinclude.h: adding XInclude
  support to the reader interface. Lot of testing of the walker,
  various bug fixes.
* xmllint.c: added --walker and made sure --xinclude --stream --debug
  works as expected
* Makefile.am result/dtd11.rdr result/ent6.rdr test/dtd11 test/ent6
  result/XInclude/*.rdr: added regression tests for the walker and
  XInclude xmlReader support, had to slightly change a couple of tests
  because the walker can't distinguish <foo/> from <foo></foo>
Daniel
  • Loading branch information...
1 parent 254b126 commit 7899c5c5d67055e6a4c6b3d4be74fa72a6145e27 Daniel Veillard committed Nov 3, 2003
View
@@ -1,3 +1,15 @@
+Mon Nov 3 13:26:32 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+ * xinclude.c xmlreader.c include/libxml/xinclude.h: adding XInclude
+ support to the reader interface. Lot of testing of the walker,
+ various bug fixes.
+ * xmllint.c: added --walker and made sure --xinclude --stream --debug
+ works as expected
+ * Makefile.am result/dtd11.rdr result/ent6.rdr test/dtd11 test/ent6
+ result/XInclude/*.rdr: added regression tests for the walker and
+ XInclude xmlReader support, had to slightly change a couple of tests
+ because the walker can't distinguish <foo/> from <foo></foo>
+
Sat Nov 1 17:42:27 CET 2003 Daniel Veillard <daniel@veillard.com>
* tree.c nanohttp.c threads.c: second BeOS patch from
View
@@ -414,6 +414,22 @@ XIncludetests : xmllint$(EXEEXT)
if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
rm result.$$name ; \
fi ; fi ; done)
+ @(echo > .memdump)
+ @echo "## XInclude xmlReader regression tests"
+ -@(for i in $(srcdir)/test/XInclude/docs/* ; do \
+ name=`basename $$i`; \
+ if [ ! -d $$i ] ; then \
+ if [ ! -f $(srcdir)/result/XInclude/$$name.rdr ] ; then \
+ echo New test file $$name ; \
+ $(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude --walker --debug $$i > $(srcdir)/result/XInclude/$$name.rdr ; \
+ grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
+ else \
+ log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude --stream --debug $$i 2>&1 > result.$$name | grep -v 'failed to load external entity' ; \
+ grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
+ diff $(srcdir)/result/XInclude/$$name.rdr result.$$name` ; \
+ if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
+ rm result.$$name ; \
+ fi ; fi ; done)
Scripttests : xmllint$(EXEEXT)
@(echo > .memdump)
@@ -547,7 +563,22 @@ Readertests : xmllint$(EXEEXT)
if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
rm result.$$name ; \
fi ; fi ; done)
-
+ @(echo > .memdump)
+ @echo "## Walker regression tests"
+ -@(for i in $(srcdir)/test/* ; do \
+ name=`basename $$i`; \
+ if [ ! -d $$i ] ; then \
+ if [ ! -f $(srcdir)/result/$$name.rdr ] ; then \
+ echo New test file $$name ; \
+ $(CHECKER) $(top_builddir)/xmllint --nonet --debug --walker $$i > $(srcdir)/result/$$name.rdr 2>/dev/null ; \
+ grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
+ else \
+ log=`$(CHECKER) $(top_builddir)/xmllint --nonet --debug --walker $$i > result.$$name 2>/dev/null ; \
+ grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
+ diff $(srcdir)/result/$$name.rdr result.$$name` ; \
+ if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
+ rm result.$$name ; \
+ fi ; fi ; done)
SAXtests : testSAX$(EXEEXT)
@(echo > .memdump)
@echo "## SAX callbacks regression tests"
View
@@ -19,11 +19,35 @@
extern "C" {
#endif
+#define XINCLUDE_NS (const xmlChar *) "http://www.w3.org/2001/XInclude"
+#define XINCLUDE_NODE (const xmlChar *) "include"
+#define XINCLUDE_FALLBACK (const xmlChar *) "fallback"
+#define XINCLUDE_HREF (const xmlChar *) "href"
+#define XINCLUDE_PARSE (const xmlChar *) "parse"
+#define XINCLUDE_PARSE_XML (const xmlChar *) "xml"
+#define XINCLUDE_PARSE_TEXT (const xmlChar *) "text"
+#define XINCLUDE_PARSE_ENCODING (const xmlChar *) "encoding"
+
+typedef struct _xmlXIncludeCtxt xmlXIncludeCtxt;
+typedef xmlXIncludeCtxt *xmlXIncludeCtxtPtr;
+
+/*
+ * standalone processing
+ */
XMLPUBFUN int XMLCALL
- xmlXIncludeProcess (xmlDocPtr doc);
+ xmlXIncludeProcess (xmlDocPtr doc);
XMLPUBFUN int XMLCALL
- xmlXIncludeProcessTree (xmlNodePtr tree);
-
+ xmlXIncludeProcessTree (xmlNodePtr tree);
+/*
+ * contextual processing
+ */
+XMLPUBFUN xmlXIncludeCtxtPtr XMLCALL
+ xmlXIncludeNewContext (xmlDocPtr doc);
+XMLPUBFUN void XMLCALL
+ xmlXIncludeFreeContext (xmlXIncludeCtxtPtr ctxt);
+XMLPUBFUN int XMLCALL
+ xmlXIncludeProcessNode (xmlXIncludeCtxtPtr ctxt,
+ xmlNodePtr tree);
#ifdef __cplusplus
}
#endif
@@ -0,0 +1,35 @@
+0 10 book 0 0
+0 1 book 0 0
+1 14 #text 0 1
+
+1 1 doc 0 0
+2 14 #text 0 1
+
+2 1 isid 1 0
+2 14 #text 0 1
+
+2 1 isid 1 0
+2 14 #text 0 1
+
+1 15 doc 0 0
+1 14 #text 0 1
+
+1 8 #comment 0 1 including another XML document with IDs
+1 14 #text 0 1
+
+1 1 doc 0 0
+2 14 #text 0 1
+
+2 1 isid 1 0
+2 14 #text 0 1
+
+2 1 isid 1 0
+2 14 #text 0 1
+
+2 1 isid 1 0
+2 14 #text 0 1
+
+1 15 doc 0 0
+1 14 #text 0 1
+
+0 15 book 0 0
@@ -0,0 +1,12 @@
+0 1 x 0 0
+1 14 #text 0 1
+
+1 8 #comment 0 1 Simple test of a fallback on unavailble URI
+1 14 #text 0 1
+
+1 1 warning 0 0
+2 3 #text 0 1 Inclusion failed
+1 15 warning 0 0
+1 14 #text 0 1
+
+0 15 x 0 0
@@ -0,0 +1,28 @@
+0 1 x 0 0
+1 14 #text 0 1
+
+1 8 #comment 0 1 Simple test of including another XML document
+1 14 #text 0 1
+
+1 1 doc 0 0
+2 14 #text 0 1
+
+2 1 p 0 0
+3 3 #text 0 1 something
+2 15 p 0 0
+2 14 #text 0 1
+
+2 1 p 0 0
+3 3 #text 0 1 really
+2 15 p 0 0
+2 14 #text 0 1
+
+2 1 p 0 0
+3 3 #text 0 1 simple
+2 15 p 0 0
+2 14 #text 0 1
+
+1 15 doc 0 0
+1 14 #text 0 1
+
+0 15 x 0 0
@@ -0,0 +1,18 @@
+0 1 x 0 0
+1 14 #text 0 1
+
+1 8 #comment 0 1 Simple test of including a set of nodes from an XML document
+1 14 #text 0 1
+
+1 1 p 0 0
+2 3 #text 0 1 something
+1 15 p 0 0
+1 1 p 0 0
+2 3 #text 0 1 really
+1 15 p 0 0
+1 1 p 0 0
+2 3 #text 0 1 simple
+1 15 p 0 0
+1 14 #text 0 1
+
+0 15 x 0 0
@@ -0,0 +1,6 @@
+0 1 this 0 0
+1 1 sub-inc 0 0
+2 3 #text 0 1 is a test
+
+1 15 sub-inc 0 0
+0 15 this 0 0
@@ -0,0 +1,11 @@
+0 1 x 0 0
+1 14 #text 0 1
+
+1 8 #comment 0 1 Simple test of including another text document
+1 14 #text 0 1
+
+1 3 #text 0 1 test with accents in ISO-8859-1: À Á é è
+
+1 14 #text 0 1
+
+0 15 x 0 0
@@ -0,0 +1,11 @@
+0 1 x 0 0
+1 14 #text 0 1
+
+1 8 #comment 0 1 Simple test of including another text document
+1 14 #text 0 1
+
+1 3 #text 0 1 this is some text in ASCII
+
+1 14 #text 0 1
+
+0 15 x 0 0
View
@@ -1,3 +1,2 @@
0 10 doc 0 0
-0 1 doc 0 0
-0 15 doc 0 0
+0 1 doc 1 0
View
@@ -1,3 +1,2 @@
0 10 doc 0 0
-0 1 doc 0 0
-0 15 doc 0 0
+0 1 doc 1 0
View
@@ -2,4 +2,4 @@
<!ELEMENT doc (#PCDATA)>
<!ATTLIST doc val CDATA #IMPLIED>
]>
-<doc val="v1"></doc>
+<doc val="v1"/>
View
@@ -5,4 +5,4 @@
<!ENTITY apos "&#39;">
<!ENTITY quot "&#34;">
]>
-<doc></doc>
+<doc/>
View
@@ -26,14 +26,6 @@
#ifdef LIBXML_XINCLUDE_ENABLED
#include <libxml/xinclude.h>
-#define XINCLUDE_NS (const xmlChar *) "http://www.w3.org/2001/XInclude"
-#define XINCLUDE_NODE (const xmlChar *) "include"
-#define XINCLUDE_FALLBACK (const xmlChar *) "fallback"
-#define XINCLUDE_HREF (const xmlChar *) "href"
-#define XINCLUDE_PARSE (const xmlChar *) "parse"
-#define XINCLUDE_PARSE_XML (const xmlChar *) "xml"
-#define XINCLUDE_PARSE_TEXT (const xmlChar *) "text"
-#define XINCLUDE_PARSE_ENCODING (const xmlChar *) "encoding"
#define XINCLUDE_MAX_DEPTH 40
@@ -68,8 +60,6 @@ struct _xmlXIncludeRef {
xmlXPathObjectPtr xptr; /* the xpointer if needed */
};
-typedef struct _xmlXIncludeCtxt xmlXIncludeCtxt;
-typedef xmlXIncludeCtxt *xmlXIncludeCtxtPtr;
struct _xmlXIncludeCtxt {
xmlDocPtr doc; /* the source document */
int incBase; /* the first include for this document */
@@ -232,7 +222,7 @@ xmlXIncludeNewRef(xmlXIncludeCtxtPtr ctxt, const xmlChar *URI,
*
* Returns the new set
*/
-static xmlXIncludeCtxtPtr
+xmlXIncludeCtxtPtr
xmlXIncludeNewContext(xmlDocPtr doc) {
xmlXIncludeCtxtPtr ret;
@@ -330,7 +320,7 @@ xmlXIncludeURLPop(xmlXIncludeCtxtPtr ctxt)
*
* Free an XInclude context
*/
-static void
+void
xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
int i;
@@ -2118,5 +2108,28 @@ xmlXIncludeProcessTree(xmlNodePtr tree) {
return(ret);
}
+/**
+ * xmlXIncludeProcessNode:
+ * @ctxt: an existing XInclude context
+ * @node: a node in an XML document
+ *
+ * Implement the XInclude substitution for the given subtree reusing
+ * the informations and data coming from the given context.
+ *
+ * Returns 0 if no substitution were done, -1 if some processing failed
+ * or the number of substitutions done.
+ */
+int
+xmlXIncludeProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
+ int ret = 0;
+
+ if ((node == NULL) || (node->doc == NULL) || (ctxt == NULL))
+ return(-1);
+ ret = xmlXIncludeDoProcess(ctxt, node->doc, node);
+ if ((ret >= 0) && (ctxt->nbErrors > 0))
+ ret = -1;
+ return(ret);
+}
+
#else /* !LIBXML_XINCLUDE_ENABLED */
#endif
Oops, something went wrong.

0 comments on commit 7899c5c

Please sign in to comment.