aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--debugXML.c90
-rw-r--r--python/libxml2class.txt500
3 files changed, 344 insertions, 250 deletions
diff --git a/ChangeLog b/ChangeLog
index 9a626b4e..c5671614 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sat Oct 9 22:36:21 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+ * debugXML.c: some framework preparation to add namespace checkings
+
Thu Oct 7 15:12:58 CEST 2004 Daniel Veillard <daniel@veillard.com>
* debugXML.c include/libxml/debugXML.h include/libxml/xmlerror.h:
diff --git a/debugXML.c b/debugXML.c
index 00f29e0a..08364e39 100644
--- a/debugXML.c
+++ b/debugXML.c
@@ -44,6 +44,9 @@ struct _xmlDebugCtxt {
xmlNodePtr node; /* current node */
int check; /* do just checkings */
int errors; /* number of errors found */
+ int nsNr; /* the number of inherited namespaces */
+ int nsMax; /* the size of the arrays */
+ xmlNsPtr *nsTab; /* the array of namespace nodes */
};
static void xmlCtxtDumpNodeList(xmlDebugCtxtPtr ctxt, xmlNodePtr node);
@@ -54,6 +57,9 @@ xmlCtxtDumpInitCtxt(xmlDebugCtxtPtr ctxt)
int i;
ctxt->depth = 0;
+ ctxt->nsNr = 0;
+ ctxt->nsMax = 0;
+ ctxt->nsTab = NULL;
ctxt->check = 0;
ctxt->errors = 0;
ctxt->output = stdout;
@@ -63,6 +69,80 @@ xmlCtxtDumpInitCtxt(xmlDebugCtxtPtr ctxt)
}
static void
+xmlCtxtDumpCleanCtxt(xmlDebugCtxtPtr ctxt)
+{
+ if (ctxt->nsTab != NULL)
+ xmlFree(ctxt->nsTab);
+}
+
+/**
+ * xmlNsCheckPush:
+ * @ctxt: an XML parser context
+ * @ns: the namespace node
+ *
+ * Pushes a new namespace on top of the ns stack
+ *
+ * Returns -1 in case of error, and the index in the stack otherwise.
+ */
+static int
+xmlNsCheckPush(xmlDebugCtxtPtr ctxt, xmlNsPtr ns)
+{
+ if (ns == NULL)
+ return(ctxt->nsNr);
+
+ if ((ctxt->nsMax == 0) || (ctxt->nsTab == NULL)) {
+ ctxt->nsMax = 10;
+ ctxt->nsNr = 0;
+ ctxt->nsTab = (xmlNsPtr *)
+ xmlMalloc(ctxt->nsMax * sizeof(ctxt->nsTab[0]));
+ if (ctxt->nsTab == NULL) {
+ xmlErrMemory(NULL, NULL);
+ ctxt->nsMax = 0;
+ return (-1);
+ }
+ } else if (ctxt->nsNr >= ctxt->nsMax) {
+ ctxt->nsMax *= 2;
+ ctxt->nsTab = (xmlNsPtr *)
+ xmlRealloc((char *) ctxt->nsTab,
+ ctxt->nsMax * sizeof(ctxt->nsTab[0]));
+ if (ctxt->nsTab == NULL) {
+ xmlErrMemory(NULL, NULL);
+ ctxt->nsMax /= 2;
+ return (-1);
+ }
+ }
+ ctxt->nsTab[ctxt->nsNr++] = ns;
+ return (ctxt->nsNr);
+}
+/**
+ * xmlNsCheckPop:
+ * @ctxt: an XML parser context
+ * @nr: the number to pop
+ *
+ * Pops the top @nr parser prefix/namespace from the ns stack
+ *
+ * Returns the number of namespaces removed
+ */
+static int
+xmlNsCheckPop(xmlDebugCtxtPtr ctxt, int nr)
+{
+ int i;
+
+ if (ctxt->nsTab == NULL) return(0);
+ if (ctxt->nsNr < nr) {
+ xmlGenericError(xmlGenericErrorContext, "Pbm popping %d NS\n", nr);
+ nr = ctxt->nsNr;
+ }
+ if (ctxt->nsNr <= 0)
+ return (0);
+
+ for (i = 0;i < nr;i++) {
+ ctxt->nsNr--;
+ ctxt->nsTab[ctxt->nsNr] = NULL;
+ }
+ return(nr);
+}
+static void
xmlCtxtDumpSpaces(xmlDebugCtxtPtr ctxt)
{
if (ctxt->check)
@@ -1101,6 +1181,7 @@ xmlDebugDumpAttr(FILE *output, xmlAttrPtr attr, int depth) {
ctxt.output = output;
ctxt.depth = depth;
xmlCtxtDumpAttr(&ctxt, attr);
+ xmlCtxtDumpCleanCtxt(&ctxt);
}
@@ -1119,6 +1200,7 @@ xmlDebugDumpEntities(FILE * output, xmlDocPtr doc)
xmlCtxtDumpInitCtxt(&ctxt);
ctxt.output = output;
xmlCtxtDumpEntities(&ctxt, doc);
+ xmlCtxtDumpCleanCtxt(&ctxt);
}
/**
@@ -1138,6 +1220,7 @@ xmlDebugDumpAttrList(FILE * output, xmlAttrPtr attr, int depth)
ctxt.output = output;
ctxt.depth = depth;
xmlCtxtDumpAttrList(&ctxt, attr);
+ xmlCtxtDumpCleanCtxt(&ctxt);
}
/**
@@ -1157,6 +1240,7 @@ xmlDebugDumpOneNode(FILE * output, xmlNodePtr node, int depth)
ctxt.output = output;
ctxt.depth = depth;
xmlCtxtDumpOneNode(&ctxt, node);
+ xmlCtxtDumpCleanCtxt(&ctxt);
}
/**
@@ -1178,6 +1262,7 @@ xmlDebugDumpNode(FILE * output, xmlNodePtr node, int depth)
ctxt.output = output;
ctxt.depth = depth;
xmlCtxtDumpNode(&ctxt, node);
+ xmlCtxtDumpCleanCtxt(&ctxt);
}
/**
@@ -1199,6 +1284,7 @@ xmlDebugDumpNodeList(FILE * output, xmlNodePtr node, int depth)
ctxt.output = output;
ctxt.depth = depth;
xmlCtxtDumpNodeList(&ctxt, node);
+ xmlCtxtDumpCleanCtxt(&ctxt);
}
/**
@@ -1218,6 +1304,7 @@ xmlDebugDumpDocumentHead(FILE * output, xmlDocPtr doc)
xmlCtxtDumpInitCtxt(&ctxt);
ctxt.output = output;
xmlCtxtDumpDocumentHead(&ctxt, doc);
+ xmlCtxtDumpCleanCtxt(&ctxt);
}
/**
@@ -1237,6 +1324,7 @@ xmlDebugDumpDocument(FILE * output, xmlDocPtr doc)
xmlCtxtDumpInitCtxt(&ctxt);
ctxt.output = output;
xmlCtxtDumpDocument(&ctxt, doc);
+ xmlCtxtDumpCleanCtxt(&ctxt);
}
/**
@@ -1256,6 +1344,7 @@ xmlDebugDumpDTD(FILE * output, xmlDtdPtr dtd)
xmlCtxtDumpInitCtxt(&ctxt);
ctxt.output = output;
xmlCtxtDumpDTD(&ctxt, dtd);
+ xmlCtxtDumpCleanCtxt(&ctxt);
}
/************************************************************************
@@ -1285,6 +1374,7 @@ xmlDebugCheckDocument(FILE * output, xmlDocPtr doc)
ctxt.output = output;
ctxt.check = 1;
xmlCtxtDumpDocument(&ctxt, doc);
+ xmlCtxtDumpCleanCtxt(&ctxt);
return(ctxt.errors);
}
diff --git a/python/libxml2class.txt b/python/libxml2class.txt
index 433da9c0..576750c6 100644
--- a/python/libxml2class.txt
+++ b/python/libxml2class.txt
@@ -647,56 +647,6 @@ Class xmlDoc(xmlNode)
# functions from module xpointer
xpointerNewContext()
-Class xpathContext()
- # accessors
- contextDoc()
- contextNode()
- contextPosition()
- contextSize()
- function()
- functionURI()
- setContextDoc()
- setContextNode()
-
- # functions from module python
- registerXPathFunction()
-
- # functions from module xpath
- xpathEval()
- xpathEvalExpression()
- xpathFreeContext()
-
- # functions from module xpathInternals
- xpathNewParserContext()
- xpathNsLookup()
- xpathRegisterAllFunctions()
- xpathRegisterNs()
- xpathRegisteredFuncsCleanup()
- xpathRegisteredNsCleanup()
- xpathRegisteredVariablesCleanup()
- xpathVariableLookup()
- xpathVariableLookupNS()
-
- # functions from module xpointer
- xpointerEval()
-
-
-Class xmlAttribute(xmlNode)
-Class catalog()
-
- # functions from module catalog
- add()
- catalogIsEmpty()
- convertSGMLCatalog()
- dump()
- remove()
- resolve()
- resolvePublic()
- resolveSystem()
- resolveURI()
-
-
-Class xmlElement(xmlNode)
Class xmlAttr(xmlNode)
@@ -715,100 +665,12 @@ Class xmlAttr(xmlNode)
# functions from module valid
removeID()
removeRef()
-
-
-Class xmlTextReader(xmlTextReaderCore)
-
- # functions from module xmlreader
- AttributeCount()
- BaseUri()
- Close()
- CurrentDoc()
- CurrentNode()
- Depth()
- Expand()
- GetAttribute()
- GetAttributeNo()
- GetAttributeNs()
- GetParserProp()
- GetRemainder()
- HasAttributes()
- HasValue()
- IsDefault()
- IsEmptyElement()
- IsValid()
- LocalName()
- LookupNamespace()
- MoveToAttribute()
- MoveToAttributeNo()
- MoveToAttributeNs()
- MoveToElement()
- MoveToFirstAttribute()
- MoveToNextAttribute()
- Name()
- NamespaceUri()
- NewDoc()
- NewFd()
- NewFile()
- NewMemory()
- NewWalker()
- Next()
- NextSibling()
- NodeType()
- Normalization()
- Prefix()
- Preserve()
- QuoteChar()
- Read()
- ReadAttributeValue()
- ReadInnerXml()
- ReadOuterXml()
- ReadState()
- ReadString()
- RelaxNGSetSchema()
- RelaxNGValidate()
- SetParserProp()
- String()
- Value()
- XmlLang()
Class xmlReg()
# functions from module xmlregexp
regexpExec()
regexpIsDeterminist()
regexpPrint()
-
-
-Class xmlEntity(xmlNode)
-
- # functions from module parserInternals
- handleEntity()
-Class relaxNgSchema()
-
- # functions from module relaxng
- relaxNGDump()
- relaxNGDumpTree()
- relaxNGNewValidCtxt()
-
- # functions from module xmlreader
- RelaxNGSetSchema()
-Class Schema()
-
- # functions from module xmlschemas
- schemaDump()
- schemaNewValidCtxt()
-Class Error()
- # accessors
- code()
- domain()
- file()
- level()
- line()
- message()
-
- # functions from module xmlerror
- copyError()
- resetError()
Class relaxNgValidCtxt()
# functions from module relaxng
@@ -817,73 +679,6 @@ Class relaxNgValidCtxt()
relaxNGValidatePopElement()
relaxNGValidatePushCData()
relaxNGValidatePushElement()
-Class xpathParserContext()
- # accessors
- context()
-
- # functions from module xpathInternals
- xpathAddValues()
- xpathBooleanFunction()
- xpathCeilingFunction()
- xpathCompareValues()
- xpathConcatFunction()
- xpathContainsFunction()
- xpathCountFunction()
- xpathDivValues()
- xpathEqualValues()
- xpathErr()
- xpathEvalExpr()
- xpathFalseFunction()
- xpathFloorFunction()
- xpathFreeParserContext()
- xpathIdFunction()
- xpathLangFunction()
- xpathLastFunction()
- xpathLocalNameFunction()
- xpathModValues()
- xpathMultValues()
- xpathNamespaceURIFunction()
- xpathNextAncestor()
- xpathNextAncestorOrSelf()
- xpathNextAttribute()
- xpathNextChild()
- xpathNextDescendant()
- xpathNextDescendantOrSelf()
- xpathNextFollowing()
- xpathNextFollowingSibling()
- xpathNextNamespace()
- xpathNextParent()
- xpathNextPreceding()
- xpathNextPrecedingSibling()
- xpathNextSelf()
- xpathNormalizeFunction()
- xpathNotEqualValues()
- xpathNotFunction()
- xpathNumberFunction()
- xpathParseNCName()
- xpathParseName()
- xpathPopBoolean()
- xpathPopNumber()
- xpathPopString()
- xpathPositionFunction()
- xpathRoot()
- xpathRoundFunction()
- xpathStartsWithFunction()
- xpathStringFunction()
- xpathStringLengthFunction()
- xpathSubValues()
- xpathSubstringAfterFunction()
- xpathSubstringBeforeFunction()
- xpathSubstringFunction()
- xpathSumFunction()
- xpathTranslateFunction()
- xpathTrueFunction()
- xpathValueFlipSign()
- xpatherror()
-
- # functions from module xpointer
- xpointerEvalRangePredicate()
- xpointerRangeToFunction()
Class parserCtxt(parserCtxtCore)
@@ -991,6 +786,94 @@ Class xmlDtd(xmlNode)
dtdElementDesc()
dtdQAttrDesc()
dtdQElementDesc()
+Class relaxNgParserCtxt()
+
+ # functions from module relaxng
+ relaxNGParse()
+ relaxParserSetFlag()
+Class xpathParserContext()
+ # accessors
+ context()
+
+ # functions from module xpathInternals
+ xpathAddValues()
+ xpathBooleanFunction()
+ xpathCeilingFunction()
+ xpathCompareValues()
+ xpathConcatFunction()
+ xpathContainsFunction()
+ xpathCountFunction()
+ xpathDivValues()
+ xpathEqualValues()
+ xpathErr()
+ xpathEvalExpr()
+ xpathFalseFunction()
+ xpathFloorFunction()
+ xpathFreeParserContext()
+ xpathIdFunction()
+ xpathLangFunction()
+ xpathLastFunction()
+ xpathLocalNameFunction()
+ xpathModValues()
+ xpathMultValues()
+ xpathNamespaceURIFunction()
+ xpathNextAncestor()
+ xpathNextAncestorOrSelf()
+ xpathNextAttribute()
+ xpathNextChild()
+ xpathNextDescendant()
+ xpathNextDescendantOrSelf()
+ xpathNextFollowing()
+ xpathNextFollowingSibling()
+ xpathNextNamespace()
+ xpathNextParent()
+ xpathNextPreceding()
+ xpathNextPrecedingSibling()
+ xpathNextSelf()
+ xpathNormalizeFunction()
+ xpathNotEqualValues()
+ xpathNotFunction()
+ xpathNumberFunction()
+ xpathParseNCName()
+ xpathParseName()
+ xpathPopBoolean()
+ xpathPopNumber()
+ xpathPopString()
+ xpathPositionFunction()
+ xpathRoot()
+ xpathRoundFunction()
+ xpathStartsWithFunction()
+ xpathStringFunction()
+ xpathStringLengthFunction()
+ xpathSubValues()
+ xpathSubstringAfterFunction()
+ xpathSubstringBeforeFunction()
+ xpathSubstringFunction()
+ xpathSumFunction()
+ xpathTranslateFunction()
+ xpathTrueFunction()
+ xpathValueFlipSign()
+ xpatherror()
+
+ # functions from module xpointer
+ xpointerEvalRangePredicate()
+ xpointerRangeToFunction()
+Class SchemaParserCtxt()
+
+ # functions from module xmlschemas
+ schemaParse()
+Class catalog()
+
+ # functions from module catalog
+ add()
+ catalogIsEmpty()
+ convertSGMLCatalog()
+ dump()
+ remove()
+ resolve()
+ resolvePublic()
+ resolveSystem()
+ resolveURI()
Class xmlNs(xmlNode)
@@ -1014,51 +897,6 @@ Class xmlNs(xmlNode)
# functions from module xpathInternals
xpathNodeSetFreeNs()
-
-
-Class inputBuffer(ioReadWrapper)
-
- # functions from module xmlIO
- grow()
- push()
- read()
-
- # functions from module xmlreader
- newTextReader()
-Class relaxNgParserCtxt()
-
- # functions from module relaxng
- relaxNGParse()
- relaxParserSetFlag()
-
-
-Class outputBuffer(ioWriteWrapper)
-
- # functions from module HTMLtree
- htmlDocContentDumpFormatOutput()
- htmlDocContentDumpOutput()
- htmlNodeDumpFormatOutput()
- htmlNodeDumpOutput()
-
- # functions from module tree
- nodeDumpOutput()
- saveFileTo()
- saveFormatFileTo()
-
- # functions from module xmlIO
- write()
- writeString()
-Class SchemaParserCtxt()
-
- # functions from module xmlschemas
- schemaParse()
-Class SchemaValidCtxt()
-
- # functions from module xmlschemas
- schemaSetValidOptions()
- schemaValidCtxtGetOptions()
- schemaValidateDoc()
- schemaValidateOneElement()
Class xmlTextReaderLocator()
# functions from module xmlreader
@@ -1089,3 +927,165 @@ Class URI()
parseURIReference()
printURI()
saveUri()
+
+
+Class xmlAttribute(xmlNode)
+Class xpathContext()
+ # accessors
+ contextDoc()
+ contextNode()
+ contextPosition()
+ contextSize()
+ function()
+ functionURI()
+ setContextDoc()
+ setContextNode()
+
+ # functions from module python
+ registerXPathFunction()
+
+ # functions from module xpath
+ xpathEval()
+ xpathEvalExpression()
+ xpathFreeContext()
+
+ # functions from module xpathInternals
+ xpathNewParserContext()
+ xpathNsLookup()
+ xpathRegisterAllFunctions()
+ xpathRegisterNs()
+ xpathRegisteredFuncsCleanup()
+ xpathRegisteredNsCleanup()
+ xpathRegisteredVariablesCleanup()
+ xpathVariableLookup()
+ xpathVariableLookupNS()
+
+ # functions from module xpointer
+ xpointerEval()
+
+
+Class xmlElement(xmlNode)
+
+
+Class xmlTextReader(xmlTextReaderCore)
+
+ # functions from module xmlreader
+ AttributeCount()
+ BaseUri()
+ Close()
+ CurrentDoc()
+ CurrentNode()
+ Depth()
+ Expand()
+ GetAttribute()
+ GetAttributeNo()
+ GetAttributeNs()
+ GetParserProp()
+ GetRemainder()
+ HasAttributes()
+ HasValue()
+ IsDefault()
+ IsEmptyElement()
+ IsValid()
+ LocalName()
+ LookupNamespace()
+ MoveToAttribute()
+ MoveToAttributeNo()
+ MoveToAttributeNs()
+ MoveToElement()
+ MoveToFirstAttribute()
+ MoveToNextAttribute()
+ Name()
+ NamespaceUri()
+ NewDoc()
+ NewFd()
+ NewFile()
+ NewMemory()
+ NewWalker()
+ Next()
+ NextSibling()
+ NodeType()
+ Normalization()
+ Prefix()
+ Preserve()
+ QuoteChar()
+ Read()
+ ReadAttributeValue()
+ ReadInnerXml()
+ ReadOuterXml()
+ ReadState()
+ ReadString()
+ RelaxNGSetSchema()
+ RelaxNGValidate()
+ SetParserProp()
+ String()
+ Value()
+ XmlLang()
+
+
+Class xmlEntity(xmlNode)
+
+ # functions from module parserInternals
+ handleEntity()
+Class Schema()
+
+ # functions from module xmlschemas
+ schemaDump()
+ schemaNewValidCtxt()
+Class Error()
+ # accessors
+ code()
+ domain()
+ file()
+ level()
+ line()
+ message()
+
+ # functions from module xmlerror
+ copyError()
+ resetError()
+Class relaxNgSchema()
+
+ # functions from module relaxng
+ relaxNGDump()
+ relaxNGDumpTree()
+ relaxNGNewValidCtxt()
+
+ # functions from module xmlreader
+ RelaxNGSetSchema()
+
+
+Class inputBuffer(ioReadWrapper)
+
+ # functions from module xmlIO
+ grow()
+ push()
+ read()
+
+ # functions from module xmlreader
+ newTextReader()
+Class SchemaValidCtxt()
+
+ # functions from module xmlschemas
+ schemaSetValidOptions()
+ schemaValidCtxtGetOptions()
+ schemaValidateDoc()
+ schemaValidateOneElement()
+
+
+Class outputBuffer(ioWriteWrapper)
+
+ # functions from module HTMLtree
+ htmlDocContentDumpFormatOutput()
+ htmlDocContentDumpOutput()
+ htmlNodeDumpFormatOutput()
+ htmlNodeDumpOutput()
+
+ # functions from module tree
+ nodeDumpOutput()
+ saveFileTo()
+ saveFormatFileTo()
+
+ # functions from module xmlIO
+ write()
+ writeString()