MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlNewDocElementContent

Function xmlNewDocElementContent

ThirdParty/libxml2/vtklibxml2/valid.c:715–782  ·  view source on GitHub ↗

* xmlNewDocElementContent: * @doc: the document * @name: the subelement name or NULL * @type: the type of element content decl * * Allocate an element content structure for the document. * * Returns NULL if not, otherwise the new element content structure */

Source from the content-addressed store, hash-verified

713 * Returns NULL if not, otherwise the new element content structure
714 */
715xmlElementContentPtr
716xmlNewDocElementContent(xmlDocPtr doc, const xmlChar *name,
717 xmlElementContentType type) {
718 xmlElementContentPtr ret;
719 xmlDictPtr dict = NULL;
720
721 if (doc != NULL)
722 dict = doc->dict;
723
724 switch(type) {
725 case XML_ELEMENT_CONTENT_ELEMENT:
726 if (name == NULL) {
727 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
728 "xmlNewElementContent : name == NULL !\n",
729 NULL);
730 }
731 break;
732 case XML_ELEMENT_CONTENT_PCDATA:
733 case XML_ELEMENT_CONTENT_SEQ:
734 case XML_ELEMENT_CONTENT_OR:
735 if (name != NULL) {
736 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
737 "xmlNewElementContent : name != NULL !\n",
738 NULL);
739 }
740 break;
741 default:
742 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
743 "Internal: ELEMENT content corrupted invalid type\n",
744 NULL);
745 return(NULL);
746 }
747 ret = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent));
748 if (ret == NULL)
749 return(NULL);
750 memset(ret, 0, sizeof(xmlElementContent));
751 ret->type = type;
752 ret->ocur = XML_ELEMENT_CONTENT_ONCE;
753 if (name != NULL) {
754 int l;
755 const xmlChar *tmp;
756
757 tmp = xmlSplitQName3(name, &l);
758 if (tmp == NULL) {
759 if (dict == NULL)
760 ret->name = xmlStrdup(name);
761 else
762 ret->name = xmlDictLookup(dict, name, -1);
763 } else {
764 if (dict == NULL) {
765 ret->prefix = xmlStrndup(name, l);
766 ret->name = xmlStrdup(tmp);
767 } else {
768 ret->prefix = xmlDictLookup(dict, name, l);
769 ret->name = xmlDictLookup(dict, tmp, -1);
770 }
771 if (ret->prefix == NULL)
772 goto error;

Calls 5

xmlSplitQName3Function · 0.85
xmlStrdupFunction · 0.85
xmlDictLookupFunction · 0.85
xmlStrndupFunction · 0.85
xmlFreeDocElementContentFunction · 0.85

Tested by

no test coverage detected