* xmlAddAttributeDecl: * @ctxt: the validation context * @dtd: pointer to the DTD * @elem: the element name * @name: the attribute name * @ns: the attribute namespace prefix * @type: the attribute type * @def: the attribute default type * @defaultValue: the attribute default value * @tree: if it's an enumeration, the associated list * * Register a new attribute declaration * N
| 1649 | * Returns NULL if not new, otherwise the attribute decl |
| 1650 | */ |
| 1651 | xmlAttributePtr |
| 1652 | xmlAddAttributeDecl(xmlValidCtxtPtr ctxt, |
| 1653 | xmlDtdPtr dtd, const xmlChar *elem, |
| 1654 | const xmlChar *name, const xmlChar *ns, |
| 1655 | xmlAttributeType type, xmlAttributeDefault def, |
| 1656 | const xmlChar *defaultValue, xmlEnumerationPtr tree) { |
| 1657 | xmlAttributePtr ret = NULL; |
| 1658 | xmlAttributeTablePtr table; |
| 1659 | xmlElementPtr elemDef; |
| 1660 | xmlDictPtr dict = NULL; |
| 1661 | int res; |
| 1662 | |
| 1663 | if (dtd == NULL) { |
| 1664 | xmlFreeEnumeration(tree); |
| 1665 | return(NULL); |
| 1666 | } |
| 1667 | if (name == NULL) { |
| 1668 | xmlFreeEnumeration(tree); |
| 1669 | return(NULL); |
| 1670 | } |
| 1671 | if (elem == NULL) { |
| 1672 | xmlFreeEnumeration(tree); |
| 1673 | return(NULL); |
| 1674 | } |
| 1675 | if (dtd->doc != NULL) |
| 1676 | dict = dtd->doc->dict; |
| 1677 | |
| 1678 | #ifdef LIBXML_VALID_ENABLED |
| 1679 | /* |
| 1680 | * Check the type and possibly the default value. |
| 1681 | */ |
| 1682 | switch (type) { |
| 1683 | case XML_ATTRIBUTE_CDATA: |
| 1684 | break; |
| 1685 | case XML_ATTRIBUTE_ID: |
| 1686 | break; |
| 1687 | case XML_ATTRIBUTE_IDREF: |
| 1688 | break; |
| 1689 | case XML_ATTRIBUTE_IDREFS: |
| 1690 | break; |
| 1691 | case XML_ATTRIBUTE_ENTITY: |
| 1692 | break; |
| 1693 | case XML_ATTRIBUTE_ENTITIES: |
| 1694 | break; |
| 1695 | case XML_ATTRIBUTE_NMTOKEN: |
| 1696 | break; |
| 1697 | case XML_ATTRIBUTE_NMTOKENS: |
| 1698 | break; |
| 1699 | case XML_ATTRIBUTE_ENUMERATION: |
| 1700 | break; |
| 1701 | case XML_ATTRIBUTE_NOTATION: |
| 1702 | break; |
| 1703 | default: |
| 1704 | xmlErrValid(ctxt, XML_ERR_ARGUMENT, |
| 1705 | "xmlAddAttributeDecl: invalid type\n", NULL); |
| 1706 | xmlFreeEnumeration(tree); |
| 1707 | return(NULL); |
| 1708 | } |
no test coverage detected