Function blocks of parser.c, attribute handling through SAX, Daniel.

This commit is contained in:
Daniel Veillard 1998-10-24 18:27:49 +00:00
parent 97b587771b
commit 11e0058a11
5 changed files with 503 additions and 140 deletions

View File

@ -1,3 +1,11 @@
Sat Oct 24 14:23:51 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* parser.c: Set up the fonctions comment block, boring but useful.
* parser.h, SAX.c, parser.c: now attributes are processed through
the SAX interface. The problem is that my SAX interface diverged
quite a bit from the original one, well this is not an official
spec, and translating it from Java to C is hairy anyway...
Tue Oct 20 02:11:21 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org> Tue Oct 20 02:11:21 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* SAX.c, entities.c, tree.c, encoding.c, error.c: Set up the * SAX.c, entities.c, tree.c, encoding.c, error.c: Set up the

26
SAX.c
View File

@ -235,6 +235,28 @@ endElement(xmlParserCtxtPtr ctxt, const CHAR *name)
#endif #endif
} }
/**
* attribute:
* @ctxt: An XML parser context
* @name: The attribute name
* @value: The attribute value
*
* called when an attribute has been read by the parser.
* The default handling is to convert the attribute into an
* DOM subtree and past it in a new xmlAttr element added to
* the element.
*
* return values:
*/
void
attribute(xmlParserCtxtPtr ctxt, const CHAR *name, const CHAR *value)
{
#ifdef DEBUG_SAX
fprintf(stderr, "SAX.attribute(%s, %s)\n", name, value);
#endif
xmlNewProp(ctxt->node, name, value);
}
/** /**
* characters: * characters:
* @ctxt: An XML parser context * @ctxt: An XML parser context
@ -323,6 +345,7 @@ xmlSAXHandler xmlDefaultSAXHandler = {
endDocument, endDocument,
startElement, startElement,
endElement, endElement,
attribute,
characters, characters,
ignorableWhitespace, ignorableWhitespace,
processingInstruction, processingInstruction,
@ -335,8 +358,6 @@ xmlSAXHandler xmlDefaultSAXHandler = {
* xmlDefaultSAXHandlerInit: * xmlDefaultSAXHandlerInit:
* *
* Initialize the default SAX handler * Initialize the default SAX handler
*
* return values:
*/ */
void void
xmlDefaultSAXHandlerInit(void) xmlDefaultSAXHandlerInit(void)
@ -349,6 +370,7 @@ xmlDefaultSAXHandlerInit(void)
xmlDefaultSAXHandler.endDocument = endDocument; xmlDefaultSAXHandler.endDocument = endDocument;
xmlDefaultSAXHandler.startElement = startElement; xmlDefaultSAXHandler.startElement = startElement;
xmlDefaultSAXHandler.endElement = endElement; xmlDefaultSAXHandler.endElement = endElement;
xmlDefaultSAXHandler.attribute = attribute;
xmlDefaultSAXHandler.characters = characters; xmlDefaultSAXHandler.characters = characters;
xmlDefaultSAXHandler.ignorableWhitespace = ignorableWhitespace; xmlDefaultSAXHandler.ignorableWhitespace = ignorableWhitespace;
xmlDefaultSAXHandler.processingInstruction = processingInstruction; xmlDefaultSAXHandler.processingInstruction = processingInstruction;

View File

@ -91,6 +91,8 @@ typedef void (*startDocumentSAXFunc) (xmlParserCtxtPtr ctxt);
typedef void (*endDocumentSAXFunc) (xmlParserCtxtPtr ctxt); typedef void (*endDocumentSAXFunc) (xmlParserCtxtPtr ctxt);
typedef void (*startElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name); typedef void (*startElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name);
typedef void (*endElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name); typedef void (*endElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name);
typedef void (*attributeSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name,
const CHAR *value);
typedef void (*charactersSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *ch, typedef void (*charactersSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *ch,
int start, int len); int start, int len);
typedef void (*ignorableWhitespaceSAXFunc) (xmlParserCtxtPtr ctxt, typedef void (*ignorableWhitespaceSAXFunc) (xmlParserCtxtPtr ctxt,
@ -110,6 +112,7 @@ typedef struct xmlSAXHandler {
endDocumentSAXFunc endDocument; endDocumentSAXFunc endDocument;
startElementSAXFunc startElement; startElementSAXFunc startElement;
endElementSAXFunc endElement; endElementSAXFunc endElement;
attributeSAXFunc attribute;
charactersSAXFunc characters; charactersSAXFunc characters;
ignorableWhitespaceSAXFunc ignorableWhitespace; ignorableWhitespaceSAXFunc ignorableWhitespace;
processingInstructionSAXFunc processingInstruction; processingInstructionSAXFunc processingInstruction;

603
parser.c

File diff suppressed because it is too large Load Diff

View File

@ -91,6 +91,8 @@ typedef void (*startDocumentSAXFunc) (xmlParserCtxtPtr ctxt);
typedef void (*endDocumentSAXFunc) (xmlParserCtxtPtr ctxt); typedef void (*endDocumentSAXFunc) (xmlParserCtxtPtr ctxt);
typedef void (*startElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name); typedef void (*startElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name);
typedef void (*endElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name); typedef void (*endElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name);
typedef void (*attributeSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name,
const CHAR *value);
typedef void (*charactersSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *ch, typedef void (*charactersSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *ch,
int start, int len); int start, int len);
typedef void (*ignorableWhitespaceSAXFunc) (xmlParserCtxtPtr ctxt, typedef void (*ignorableWhitespaceSAXFunc) (xmlParserCtxtPtr ctxt,
@ -110,6 +112,7 @@ typedef struct xmlSAXHandler {
endDocumentSAXFunc endDocument; endDocumentSAXFunc endDocument;
startElementSAXFunc startElement; startElementSAXFunc startElement;
endElementSAXFunc endElement; endElementSAXFunc endElement;
attributeSAXFunc attribute;
charactersSAXFunc characters; charactersSAXFunc characters;
ignorableWhitespaceSAXFunc ignorableWhitespace; ignorableWhitespaceSAXFunc ignorableWhitespace;
processingInstructionSAXFunc processingInstruction; processingInstructionSAXFunc processingInstruction;