* xmlNewDtd: * @doc: the document pointer (optional) * @name: the DTD name (optional) * @ExternalID: the external ID (optional) * @SystemID: the system ID (optional) * * Create a DTD node. * * If a document is provided, it is an error if it already has an * external subset. If the document has no external subset, it * will be set to the created DTD. * * To create an internal subset
| 846 | * invalid or a memory allocation failed. |
| 847 | */ |
| 848 | xmlDtdPtr |
| 849 | xmlNewDtd(xmlDocPtr doc, const xmlChar *name, |
| 850 | const xmlChar *ExternalID, const xmlChar *SystemID) { |
| 851 | xmlDtdPtr cur; |
| 852 | |
| 853 | if ((doc != NULL) && (doc->extSubset != NULL)) { |
| 854 | return(NULL); |
| 855 | } |
| 856 | |
| 857 | /* |
| 858 | * Allocate a new DTD and fill the fields. |
| 859 | */ |
| 860 | cur = (xmlDtdPtr) xmlMalloc(sizeof(xmlDtd)); |
| 861 | if (cur == NULL) |
| 862 | return(NULL); |
| 863 | memset(cur, 0 , sizeof(xmlDtd)); |
| 864 | cur->type = XML_DTD_NODE; |
| 865 | |
| 866 | if (name != NULL) { |
| 867 | cur->name = xmlStrdup(name); |
| 868 | if (cur->name == NULL) |
| 869 | goto error; |
| 870 | } |
| 871 | if (ExternalID != NULL) { |
| 872 | cur->ExternalID = xmlStrdup(ExternalID); |
| 873 | if (cur->ExternalID == NULL) |
| 874 | goto error; |
| 875 | } |
| 876 | if (SystemID != NULL) { |
| 877 | cur->SystemID = xmlStrdup(SystemID); |
| 878 | if (cur->SystemID == NULL) |
| 879 | goto error; |
| 880 | } |
| 881 | if (doc != NULL) |
| 882 | doc->extSubset = cur; |
| 883 | cur->doc = doc; |
| 884 | |
| 885 | if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) |
| 886 | xmlRegisterNodeDefaultValue((xmlNodePtr)cur); |
| 887 | return(cur); |
| 888 | |
| 889 | error: |
| 890 | xmlFreeDtd(cur); |
| 891 | return(NULL); |
| 892 | } |
| 893 | |
| 894 | /** |
| 895 | * xmlGetIntSubset: |
no test coverage detected