1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

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
This commit is contained in:
Daniel Veillard 2004-01-25 19:54:59 +00:00
parent dda22c15d5
commit 03c2f0a41d
5 changed files with 87 additions and 11 deletions

View File

@ -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

View File

@ -82,6 +82,16 @@ typedef enum {
XML_RELAXNG_ERR_TEXTWRONG
} 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.
*/
@ -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

View File

@ -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,

View File

@ -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

View File

@ -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) {