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

Function xmlRelaxNGCleanupAttributes

ThirdParty/libxml2/vtklibxml2/relaxng.c:6810–6888  ·  view source on GitHub ↗

* xmlRelaxNGCleanupAttributes: * @ctxt: a Relax-NG parser context * @node: a Relax-NG node * * Check all the attributes on the given node */

Source from the content-addressed store, hash-verified

6808 * Check all the attributes on the given node
6809 */
6810static void
6811xmlRelaxNGCleanupAttributes(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node)
6812{
6813 xmlAttrPtr cur, next;
6814
6815 cur = node->properties;
6816 while (cur != NULL) {
6817 next = cur->next;
6818 if ((cur->ns == NULL) ||
6819 (xmlStrEqual(cur->ns->href, xmlRelaxNGNs))) {
6820 if (xmlStrEqual(cur->name, BAD_CAST "name")) {
6821 if ((!xmlStrEqual(node->name, BAD_CAST "element")) &&
6822 (!xmlStrEqual(node->name, BAD_CAST "attribute")) &&
6823 (!xmlStrEqual(node->name, BAD_CAST "ref")) &&
6824 (!xmlStrEqual(node->name, BAD_CAST "parentRef")) &&
6825 (!xmlStrEqual(node->name, BAD_CAST "param")) &&
6826 (!xmlStrEqual(node->name, BAD_CAST "define"))) {
6827 xmlRngPErr(ctxt, node, XML_RNGP_FORBIDDEN_ATTRIBUTE,
6828 "Attribute %s is not allowed on %s\n",
6829 cur->name, node->name);
6830 }
6831 } else if (xmlStrEqual(cur->name, BAD_CAST "type")) {
6832 if ((!xmlStrEqual(node->name, BAD_CAST "value")) &&
6833 (!xmlStrEqual(node->name, BAD_CAST "data"))) {
6834 xmlRngPErr(ctxt, node, XML_RNGP_FORBIDDEN_ATTRIBUTE,
6835 "Attribute %s is not allowed on %s\n",
6836 cur->name, node->name);
6837 }
6838 } else if (xmlStrEqual(cur->name, BAD_CAST "href")) {
6839 if ((!xmlStrEqual(node->name, BAD_CAST "externalRef")) &&
6840 (!xmlStrEqual(node->name, BAD_CAST "include"))) {
6841 xmlRngPErr(ctxt, node, XML_RNGP_FORBIDDEN_ATTRIBUTE,
6842 "Attribute %s is not allowed on %s\n",
6843 cur->name, node->name);
6844 }
6845 } else if (xmlStrEqual(cur->name, BAD_CAST "combine")) {
6846 if ((!xmlStrEqual(node->name, BAD_CAST "start")) &&
6847 (!xmlStrEqual(node->name, BAD_CAST "define"))) {
6848 xmlRngPErr(ctxt, node, XML_RNGP_FORBIDDEN_ATTRIBUTE,
6849 "Attribute %s is not allowed on %s\n",
6850 cur->name, node->name);
6851 }
6852 } else if (xmlStrEqual(cur->name, BAD_CAST "datatypeLibrary")) {
6853 xmlChar *val;
6854 xmlURIPtr uri;
6855
6856 val = xmlNodeListGetString(node->doc, cur->children, 1);
6857 if (val != NULL) {
6858 if (val[0] != 0) {
6859 uri = xmlParseURI((const char *) val);
6860 if (uri == NULL) {
6861 xmlRngPErr(ctxt, node, XML_RNGP_INVALID_URI,
6862 "Attribute %s contains invalid URI %s\n",
6863 cur->name, val);
6864 } else {
6865 if (uri->scheme == NULL) {
6866 xmlRngPErr(ctxt, node, XML_RNGP_URI_NOT_ABSOLUTE,
6867 "Attribute %s URI %s is not absolute\n",

Callers 1

xmlRelaxNGCleanupTreeFunction · 0.85

Calls 4

xmlStrEqualFunction · 0.85
xmlNodeListGetStringFunction · 0.85
xmlParseURIFunction · 0.85
xmlFreeURIFunction · 0.85

Tested by

no test coverage detected