mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-17 18:21:05 +03:00
incomplete steps for real/double support avoiding a compilation problem
* xmlschemastypes.c: incomplete steps for real/double support * testAutomata.c include/libxml/xmlautomata.h include/libxml/xmlregexp.h: avoiding a compilation problem * valid.c include/libxml/valid.h: starting the work toward using the regexps for actual DTD validation Daniel
This commit is contained in:
@ -1,3 +1,11 @@
|
|||||||
|
Mon Sep 17 12:38:08 CEST 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* xmlschemastypes.c: incomplete steps for real/double support
|
||||||
|
* testAutomata.c include/libxml/xmlautomata.h
|
||||||
|
include/libxml/xmlregexp.h: avoiding a compilation problem
|
||||||
|
* valid.c include/libxml/valid.h: starting the work toward using
|
||||||
|
the regexps for actual DTD validation
|
||||||
|
|
||||||
Fri Sep 13 16:46:14 CEST 2002 Daniel Veillard <daniel@veillard.com>
|
Fri Sep 13 16:46:14 CEST 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* hash.c: cosmetic cleanup
|
* hash.c: cosmetic cleanup
|
||||||
|
@ -298,6 +298,15 @@ int xmlValidateNameValue (const xmlChar *value);
|
|||||||
int xmlValidateNamesValue (const xmlChar *value);
|
int xmlValidateNamesValue (const xmlChar *value);
|
||||||
int xmlValidateNmtokenValue (const xmlChar *value);
|
int xmlValidateNmtokenValue (const xmlChar *value);
|
||||||
int xmlValidateNmtokensValue(const xmlChar *value);
|
int xmlValidateNmtokensValue(const xmlChar *value);
|
||||||
|
|
||||||
|
#ifdef LIBXML_REGEXP_ENABLED
|
||||||
|
/*
|
||||||
|
* Validation based on the regexp support
|
||||||
|
*/
|
||||||
|
int xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,
|
||||||
|
xmlElementPtr elem);
|
||||||
|
|
||||||
|
#endif /* LIBXML_REGEXP_ENABLED */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,8 +14,9 @@
|
|||||||
#else
|
#else
|
||||||
#include <libxml/xmlversion.h>
|
#include <libxml/xmlversion.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef LIBXML_AUTOMATA_ENABLED
|
#include <libxml/tree.h>
|
||||||
|
|
||||||
|
#ifdef LIBXML_AUTOMATA_ENABLED
|
||||||
#include <libxml/xmlregexp.h>
|
#include <libxml/xmlregexp.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#ifdef LIBXML_REGEXP_ENABLED
|
#ifdef LIBXML_REGEXP_ENABLED
|
||||||
|
|
||||||
#include <libxml/tree.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -39,6 +38,14 @@ typedef xmlRegexp *xmlRegexpPtr;
|
|||||||
typedef struct _xmlRegExecCtxt xmlRegExecCtxt;
|
typedef struct _xmlRegExecCtxt xmlRegExecCtxt;
|
||||||
typedef xmlRegExecCtxt *xmlRegExecCtxtPtr;
|
typedef xmlRegExecCtxt *xmlRegExecCtxtPtr;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#include <libxml/tree.h>
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The POSIX like API
|
* The POSIX like API
|
||||||
*/
|
*/
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "libxml.h"
|
#include "libxml.h"
|
||||||
#ifdef LIBXML_AUTOMATA_ENABLED
|
#ifdef LIBXML_AUTOMATA_ENABLED
|
||||||
|
|
||||||
|
#include <libxml/tree.h>
|
||||||
#include <libxml/xmlautomata.h>
|
#include <libxml/xmlautomata.h>
|
||||||
|
|
||||||
static int scanNumber(char **ptr) {
|
static int scanNumber(char **ptr) {
|
||||||
|
36
valid.c
36
valid.c
@ -366,7 +366,7 @@ xmlAttributePtr xmlScanAttributeDecl(xmlDtdPtr dtd, const xmlChar *elem);
|
|||||||
*
|
*
|
||||||
* Generate the automata sequence needed for that type
|
* Generate the automata sequence needed for that type
|
||||||
*
|
*
|
||||||
* Returns 0 if successful or -1 in case of error.
|
* Returns 1 if successful or 0 in case of error.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xmlValidBuildAContentModel(xmlElementContentPtr content,
|
xmlValidBuildAContentModel(xmlElementContentPtr content,
|
||||||
@ -375,13 +375,13 @@ xmlValidBuildAContentModel(xmlElementContentPtr content,
|
|||||||
if (content == NULL) {
|
if (content == NULL) {
|
||||||
VERROR(ctxt->userData,
|
VERROR(ctxt->userData,
|
||||||
"Found unexpected type = NULL in %s content model\n", name);
|
"Found unexpected type = NULL in %s content model\n", name);
|
||||||
return(-1);
|
return(0);
|
||||||
}
|
}
|
||||||
switch (content->type) {
|
switch (content->type) {
|
||||||
case XML_ELEMENT_CONTENT_PCDATA:
|
case XML_ELEMENT_CONTENT_PCDATA:
|
||||||
VERROR(ctxt->userData, "ContentModel found PCDATA for element %s\n",
|
VERROR(ctxt->userData, "ContentModel found PCDATA for element %s\n",
|
||||||
name);
|
name);
|
||||||
return(-1);
|
return(0);
|
||||||
break;
|
break;
|
||||||
case XML_ELEMENT_CONTENT_ELEMENT: {
|
case XML_ELEMENT_CONTENT_ELEMENT: {
|
||||||
xmlAutomataStatePtr oldstate = ctxt->state;
|
xmlAutomataStatePtr oldstate = ctxt->state;
|
||||||
@ -479,9 +479,9 @@ xmlValidBuildAContentModel(xmlElementContentPtr content,
|
|||||||
default:
|
default:
|
||||||
VERROR(ctxt->userData, "ContentModel broken for element %s\n",
|
VERROR(ctxt->userData, "ContentModel broken for element %s\n",
|
||||||
name);
|
name);
|
||||||
return(-1);
|
return(0);
|
||||||
}
|
}
|
||||||
return(0);
|
return(1);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* xmlValidBuildContentModel:
|
* xmlValidBuildContentModel:
|
||||||
@ -491,31 +491,32 @@ xmlValidBuildAContentModel(xmlElementContentPtr content,
|
|||||||
* (Re)Build the automata associated to the content model of this
|
* (Re)Build the automata associated to the content model of this
|
||||||
* element
|
* element
|
||||||
*
|
*
|
||||||
* Returns 0 in case of success, -1 in case of error
|
* Returns 1 in case of success, 0 in case of error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, xmlElementPtr elem) {
|
xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, xmlElementPtr elem) {
|
||||||
xmlAutomataStatePtr start;
|
xmlAutomataStatePtr start;
|
||||||
|
|
||||||
if ((ctxt == NULL) || (elem == NULL))
|
if ((ctxt == NULL) || (elem == NULL))
|
||||||
return(-1);
|
|
||||||
if (elem->type != XML_ELEMENT_DECL)
|
|
||||||
return(-1);
|
|
||||||
if (elem->etype != XML_ELEMENT_TYPE_ELEMENT)
|
|
||||||
return(0);
|
return(0);
|
||||||
|
if (elem->type != XML_ELEMENT_DECL)
|
||||||
|
return(0);
|
||||||
|
if (elem->etype != XML_ELEMENT_TYPE_ELEMENT)
|
||||||
|
return(1);
|
||||||
/* TODO: should we rebuild in this case ? */
|
/* TODO: should we rebuild in this case ? */
|
||||||
if (elem->contModel != NULL)
|
if (elem->contModel != NULL)
|
||||||
return(0);
|
return(1);
|
||||||
|
|
||||||
ctxt->am = xmlNewAutomata();
|
ctxt->am = xmlNewAutomata();
|
||||||
if (ctxt->am == NULL) {
|
if (ctxt->am == NULL) {
|
||||||
VERROR(ctxt->userData, "Cannot create automata for element %s\n",
|
VERROR(ctxt->userData, "Cannot create automata for element %s\n",
|
||||||
elem->name);
|
elem->name);
|
||||||
return(-1);
|
return(0);
|
||||||
}
|
}
|
||||||
start = ctxt->state = xmlAutomataGetInitState(ctxt->am);
|
start = ctxt->state = xmlAutomataGetInitState(ctxt->am);
|
||||||
xmlValidBuildAContentModel(elem->content, ctxt, elem->name);
|
xmlValidBuildAContentModel(elem->content, ctxt, elem->name);
|
||||||
xmlAutomataSetFinalState(ctxt->am, ctxt->state);
|
xmlAutomataSetFinalState(ctxt->am, ctxt->state);
|
||||||
|
elem->contModel = xmlAutomataCompile(ctxt->am);
|
||||||
if (!xmlAutomataIsDeterminist(ctxt->am)) {
|
if (!xmlAutomataIsDeterminist(ctxt->am)) {
|
||||||
VERROR(ctxt->userData, "Content model of %s is not determinist:\n",
|
VERROR(ctxt->userData, "Content model of %s is not determinist:\n",
|
||||||
elem->name);
|
elem->name);
|
||||||
@ -524,7 +525,7 @@ xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, xmlElementPtr elem) {
|
|||||||
ctxt->state = NULL;
|
ctxt->state = NULL;
|
||||||
xmlFreeAutomata(ctxt->am);
|
xmlFreeAutomata(ctxt->am);
|
||||||
ctxt->am = NULL;
|
ctxt->am = NULL;
|
||||||
return(0);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* LIBXML_REGEXP_ENABLED */
|
#endif /* LIBXML_REGEXP_ENABLED */
|
||||||
@ -918,6 +919,10 @@ xmlFreeElement(xmlElementPtr elem) {
|
|||||||
xmlFree((xmlChar *) elem->name);
|
xmlFree((xmlChar *) elem->name);
|
||||||
if (elem->prefix != NULL)
|
if (elem->prefix != NULL)
|
||||||
xmlFree((xmlChar *) elem->prefix);
|
xmlFree((xmlChar *) elem->prefix);
|
||||||
|
#ifdef LIBXML_REGEXP_ENABLED
|
||||||
|
if (elem->contModel != NULL)
|
||||||
|
xmlRegFreeRegexp(elem->contModel);
|
||||||
|
#endif
|
||||||
xmlFree(elem);
|
xmlFree(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3513,6 +3518,11 @@ xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
|
|||||||
|
|
||||||
if (elem == NULL) return(1);
|
if (elem == NULL) return(1);
|
||||||
|
|
||||||
|
#ifdef LIBXML_REGEXP_ENABLED
|
||||||
|
/* Build the regexp associated to the content model */
|
||||||
|
ret = xmlValidBuildContentModel(ctxt, elem);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* No Duplicate Types */
|
/* No Duplicate Types */
|
||||||
if (elem->etype == XML_ELEMENT_TYPE_MIXED) {
|
if (elem->etype == XML_ELEMENT_TYPE_MIXED) {
|
||||||
xmlElementContentPtr cur, next;
|
xmlElementContentPtr cur, next;
|
||||||
|
@ -51,6 +51,8 @@ typedef enum {
|
|||||||
XML_SCHEMAS_DATE,
|
XML_SCHEMAS_DATE,
|
||||||
XML_SCHEMAS_DATETIME,
|
XML_SCHEMAS_DATETIME,
|
||||||
XML_SCHEMAS_DURATION,
|
XML_SCHEMAS_DURATION,
|
||||||
|
XML_SCHEMAS_FLOAT,
|
||||||
|
XML_SCHEMAS_DOUBLE,
|
||||||
XML_SCHEMAS_,
|
XML_SCHEMAS_,
|
||||||
XML_SCHEMAS_XXX
|
XML_SCHEMAS_XXX
|
||||||
} xmlSchemaValType;
|
} xmlSchemaValType;
|
||||||
@ -100,6 +102,8 @@ struct _xmlSchemaVal {
|
|||||||
xmlSchemaValDecimal decimal;
|
xmlSchemaValDecimal decimal;
|
||||||
xmlSchemaValDate date;
|
xmlSchemaValDate date;
|
||||||
xmlSchemaValDuration dur;
|
xmlSchemaValDuration dur;
|
||||||
|
float f;
|
||||||
|
double d;
|
||||||
} value;
|
} value;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -122,6 +126,8 @@ static xmlSchemaTypePtr xmlSchemaTypeDurationDef = NULL;
|
|||||||
static xmlSchemaTypePtr xmlSchemaTypePositiveIntegerDef = NULL;
|
static xmlSchemaTypePtr xmlSchemaTypePositiveIntegerDef = NULL;
|
||||||
static xmlSchemaTypePtr xmlSchemaTypeNonNegativeIntegerDef = NULL;
|
static xmlSchemaTypePtr xmlSchemaTypeNonNegativeIntegerDef = NULL;
|
||||||
static xmlSchemaTypePtr xmlSchemaTypeNmtoken = NULL;
|
static xmlSchemaTypePtr xmlSchemaTypeNmtoken = NULL;
|
||||||
|
static xmlSchemaTypePtr xmlSchemaTypeFloatDef = NULL;
|
||||||
|
static xmlSchemaTypePtr xmlSchemaTypeDoubleDef = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xmlSchemaInitBasicType:
|
* xmlSchemaInitBasicType:
|
||||||
@ -176,6 +182,8 @@ xmlSchemaInitTypes(void) {
|
|||||||
xmlSchemaTypeNonNegativeIntegerDef =
|
xmlSchemaTypeNonNegativeIntegerDef =
|
||||||
xmlSchemaInitBasicType("nonNegativeInteger");
|
xmlSchemaInitBasicType("nonNegativeInteger");
|
||||||
xmlSchemaTypeNmtoken = xmlSchemaInitBasicType("NMTOKEN");
|
xmlSchemaTypeNmtoken = xmlSchemaInitBasicType("NMTOKEN");
|
||||||
|
xmlSchemaTypeFloatDef = xmlSchemaInitBasicType("float");
|
||||||
|
xmlSchemaTypeDoubleDef = xmlSchemaInitBasicType("double");
|
||||||
|
|
||||||
xmlSchemaTypesInitialized = 1;
|
xmlSchemaTypesInitialized = 1;
|
||||||
}
|
}
|
||||||
@ -1059,6 +1067,34 @@ xmlSchemaValidatePredefinedType(xmlSchemaTypePtr type, const xmlChar *value,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
|
} else if (type == xmlSchemaTypeFloatDef) {
|
||||||
|
const xmlChar *cur = value, *tmp;
|
||||||
|
int frac = 0, len, neg = 0;
|
||||||
|
unsigned long base = 0;
|
||||||
|
if (cur == NULL)
|
||||||
|
return(1);
|
||||||
|
if (*cur == '+')
|
||||||
|
cur++;
|
||||||
|
else if (*cur == '-') {
|
||||||
|
neg = 1;
|
||||||
|
cur++;
|
||||||
|
}
|
||||||
|
tmp = cur;
|
||||||
|
while ((*cur >= '0') && (*cur <= '9')) {
|
||||||
|
base = base * 10 + (*cur - '0');
|
||||||
|
cur++;
|
||||||
|
}
|
||||||
|
len = cur - tmp;
|
||||||
|
if (*cur == '.') {
|
||||||
|
cur++;
|
||||||
|
tmp = cur;
|
||||||
|
while ((*cur >= '0') && (*cur <= '9')) {
|
||||||
|
base = base * 10 + (*cur - '0');
|
||||||
|
cur++;
|
||||||
|
}
|
||||||
|
frac = cur - tmp;
|
||||||
|
}
|
||||||
|
} else if (type == xmlSchemaTypeDoubleDef) {
|
||||||
} else {
|
} else {
|
||||||
TODO
|
TODO
|
||||||
return(0);
|
return(0);
|
||||||
|
Reference in New Issue
Block a user