summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2004-01-25 19:54:59 +0000
committerDaniel Veillard <veillard@src.gnome.org>2004-01-25 19:54:59 +0000
commit03c2f0a41d11ce26510a601f8a0ef9afa6c9a828 (patch)
tree0c5801493823dca17e0ceed04036eb5f9f010bae
parentdda22c15d5447b4a2a7bd47d456bcc5bbcef2472 (diff)
downloadlibxml2-03c2f0a41d11ce26510a601f8a0ef9afa6c9a828.tar.gz
fixing #130453 XInclude element with no href attribute fully integrating
* xinclude.c: fixing #130453 XInclude element with no href attribute * relaxng.c rngparser.c include/libxml2/relaxng.h: fully integrating the compact syntax will require more work, postponed for the 2.6.5 release. Daniel
-rw-r--r--ChangeLog7
-rw-r--r--include/libxml/relaxng.h14
-rw-r--r--relaxng.c36
-rw-r--r--rngparser.c34
-rw-r--r--xinclude.c7
5 files changed, 87 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index d7b818a2..cc46bf95 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sun Jan 25 20:52:09 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+ * xinclude.c: fixing #130453 XInclude element with no href attribute
+ * relaxng.c rngparser.c include/libxml2/relaxng.h: fully integrating
+ the compact syntax will require more work, postponed for the
+ 2.6.5 release.
+
Sat Jan 24 09:30:22 CET 2004 Daniel Veillard <daniel@veillard.com>
* include/libxml/schemasInternals.h xmlschemas.c: applied patch from
diff --git a/include/libxml/relaxng.h b/include/libxml/relaxng.h
index 3743f3e6..e9702896 100644
--- a/include/libxml/relaxng.h
+++ b/include/libxml/relaxng.h
@@ -83,6 +83,16 @@ typedef enum {
} xmlRelaxNGValidErr;
/*
+ * xmlRelaxNGParserFlags:
+ *
+ * List of possible Relax NG Parser flags
+ */
+typedef enum {
+ XML_RELAXNGP_NONE = 0,
+ XML_RELAXNGP_FREE_DOC = 1,
+ XML_RELAXNGP_CRNG = 2
+} xmlRelaxNGParserFlag;
+/*
* Interfaces for parsing.
*/
XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
@@ -93,6 +103,10 @@ XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
xmlRelaxNGNewDocParserCtxt (xmlDocPtr doc);
+XMLPUBFUN int XMLCALL
+ xmlRelaxParserSetFlag (xmlRelaxNGParserCtxtPtr ctxt,
+ int flag);
+
XMLPUBFUN void XMLCALL
xmlRelaxNGFreeParserCtxt (xmlRelaxNGParserCtxtPtr ctxt);
XMLPUBFUN void XMLCALL
diff --git a/relaxng.c b/relaxng.c
index 985eff27..dcaf8802 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -246,6 +246,8 @@ struct _xmlRelaxNGParserCtxt {
/* used to compile content models */
xmlAutomataPtr am; /* the automata */
xmlAutomataStatePtr state; /* used to build the automata */
+
+ int crng; /* compact syntax and other flags */
};
#define FLAGS_IGNORABLE 1
@@ -1382,7 +1384,39 @@ xmlRelaxNGFreeValidState(xmlRelaxNGValidCtxtPtr ctxt,
/************************************************************************
* *
- * Document functions *
+ * Semi internal functions *
+ * *
+ ************************************************************************/
+
+/**
+ * xmlRelaxParserSetFlag:
+ * @ctxt: a RelaxNG parser context
+ * @flags: a set of flags values
+ *
+ * Semi private function used to pass informations to a parser context
+ * which are a combination of xmlRelaxNGParserFlag .
+ *
+ * Returns 0 if success and -1 in case of error
+ */
+int
+xmlRelaxParserSetFlag(xmlRelaxNGParserCtxtPtr ctxt, int flags)
+{
+ if (ctxt == NULL) return(-1);
+ if (flags & XML_RELAXNGP_FREE_DOC) {
+ ctxt->crng |= XML_RELAXNGP_FREE_DOC;
+ flags -= XML_RELAXNGP_FREE_DOC;
+ }
+ if (flags & XML_RELAXNGP_CRNG) {
+ ctxt->crng |= XML_RELAXNGP_CRNG;
+ flags -= XML_RELAXNGP_CRNG;
+ }
+ if (flags != 0) return(-1);
+ return(0);
+}
+
+/************************************************************************
+ * *
+ * Document functions *
* *
************************************************************************/
static xmlDocPtr xmlRelaxNGCleanupDoc(xmlRelaxNGParserCtxtPtr ctxt,
diff --git a/rngparser.c b/rngparser.c
index 67a25b7f..bc72f6b3 100644
--- a/rngparser.c
+++ b/rngparser.c
@@ -1,6 +1,11 @@
/**
* rngparser.c: parser for the Relax-NG compact syntax.
*
+ * Based on:
+ * RELAX NG Compact Syntax
+ * Committee Specification 21 November 2002
+ * http://www.oasis-open.org/committees/relax-ng/compact-20021121.html
+ *
* See Copyright for the status of this software.
*
* Daniel Veillard <veillard@redhat.com>
@@ -1417,17 +1422,18 @@ xmlParseCRNG_topLevel(xmlCRelaxNGParserCtxtPtr ctxt)
}
/**
- * xmlParseCRNG:
+ * xmlConvertCRNG:
* @schemas: pointer to the text of the compact schemas
* @len: length of the schemas in bytes (or 0)
+ * @encoding: encoding indicated by the context or NULL
*
* Compiles the schemas into the equivalent Relax-NG XML structure
*
* Returns the xmlDocPtr resulting from the compilation or
* NULL in case of error
*/
-static xmlDocPtr
-xmlParseCRNG(const xmlChar *schemas, int len) {
+xmlDocPtr
+xmlConvertCRNG(const char *schemas, int len, const char *encoding) {
struct _xmlCRelaxNGParserCtxt ctxt;
xmlDocPtr ret = NULL;
@@ -1484,8 +1490,8 @@ xmlParseCRNG(const xmlChar *schemas, int len) {
ctxt.key_ref = xmlDictLookup(ctxt.dict, BAD_CAST "ref", 3);
ctxt.key_define = xmlDictLookup(ctxt.dict, BAD_CAST "define", 6);
- /* xmlParseCRNGTokenize(&ctxt); */
- xmlParseCRNG_topLevel(&ctxt);
+ /* xmlConvertCRNGTokenize(&ctxt); */
+ xmlConvertCRNG_topLevel(&ctxt);
xmlDictFree(ctxt.dict);
@@ -1493,6 +1499,21 @@ xmlParseCRNG(const xmlChar *schemas, int len) {
return(ret);
}
+/**
+ * xmlConvertCRNGFile:
+ * @URL: URL or filename for the resource
+ * @encoding: encoding indicated by the context or NULL
+ *
+ * Compiles the schemas into the equivalent Relax-NG XML structure
+ *
+ * Returns the xmlDocPtr resulting from the compilation or
+ * NULL in case of error
+ */
+xmlDocPtr
+xmlConvertCRNG(const char *URL, const char *encoding) {
+}
+
+#ifdef STANDALONE
const xmlChar *schemas =
"# RELAX NG XML syntax specified in compact syntax.\n\
\n\
@@ -1562,10 +1583,11 @@ anyAttribute = attribute * { text }\n\
int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
xmlDocPtr res;
- res = xmlParseCRNG(schemas, -1);
+ res = xmlConvertCRNG(schemas, -1);
if (res != NULL) {
xmlDocFormatDump(stdout, res, 1);
xmlFreeDoc(res);
}
return(0);
}
+#endif
diff --git a/xinclude.c b/xinclude.c
index e4f98217..56f73500 100644
--- a/xinclude.c
+++ b/xinclude.c
@@ -1841,10 +1841,9 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
*/
href = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_HREF);
if (href == NULL) {
- /* @@@@ */
- xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
- XML_XINCLUDE_NO_HREF, "no href\n", NULL);
- return(-1);
+ href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */
+ if (href == NULL)
+ return(-1);
}
parse = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE);
if (parse != NULL) {