/* * Attribute.c : implementation of the Attribute interface as defined by * Document Object Model (Core) Level 1 * http://www.w3.org/TR/WD-DOM/level-one-core.html * * Daniel.Veillard@w3.org * * $Id: Attribute.c,v 1.1 1998/06/15 01:23:53 daniel Exp $ */ #include "config.h" #include #include #include #include "Attribute.h" #include "Element.h" /* * Create a new Attribute. */ domAttributePtr domAttributeCreate(char *name, char *value) { domAttributePtr ret; if (name == NULL) return(NULL); ret = (domAttributePtr) malloc(sizeof(domAttribute)); if (ret == NULL) { fprintf(stderr, "domAttributeCreate : out of memory\n"); return(NULL); } memset(ret, 0, sizeof(domAttribute)); ret->name = strdup(name); if (value != NULL) ret->value = strdup(value); return(ret); } /* * Destroy an Attribute. */ void domAttributeDestroy(domAttributePtr attr) { if (attr == NULL) return; memset(attr, 0, sizeof(domAttribute)); attr->name = (void *) 0xdeadbeef; attr->value = (void *) 0xdeadbeef; free(attr); } /* * Get the attribute name. */ char *getName(domAttributePtr atr) { if (atr == NULL) return(NULL); return(atr->name); /* Should we duplicate ??? */ } /* * Get the attribute value, without entity substitution. */ char *getValue(domAttributePtr atr) { if (atr == NULL) return(NULL); return(atr->value); /* Should we duplicate ??? */ } /* * Get the attribute value, with entity substitution. */ char *toString(domAttributePtr atr) { if (atr == NULL) return(NULL); return(atr->value); /* TODO !!! Entity subst (done by the parser ???) */ }