| 3808 | */ |
| 3809 | |
| 3810 | xmlChar * |
| 3811 | xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc, |
| 3812 | xmlNodePtr elem, const xmlChar *name, const xmlChar *value) { |
| 3813 | xmlChar *ret; |
| 3814 | xmlAttributePtr attrDecl = NULL; |
| 3815 | const xmlChar *localName; |
| 3816 | xmlChar *prefix = NULL; |
| 3817 | int extsubset = 0; |
| 3818 | |
| 3819 | if (doc == NULL) return(NULL); |
| 3820 | if (elem == NULL) return(NULL); |
| 3821 | if (name == NULL) return(NULL); |
| 3822 | if (value == NULL) return(NULL); |
| 3823 | |
| 3824 | localName = xmlSplitQName4(name, &prefix); |
| 3825 | if (localName == NULL) |
| 3826 | goto mem_error; |
| 3827 | |
| 3828 | if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) { |
| 3829 | xmlChar buf[50]; |
| 3830 | xmlChar *elemname; |
| 3831 | |
| 3832 | elemname = xmlBuildQName(elem->name, elem->ns->prefix, buf, 50); |
| 3833 | if (elemname == NULL) |
| 3834 | goto mem_error; |
| 3835 | if (doc->intSubset != NULL) |
| 3836 | attrDecl = xmlHashLookup3(doc->intSubset->attributes, localName, |
| 3837 | prefix, elemname); |
| 3838 | if ((attrDecl == NULL) && (doc->extSubset != NULL)) { |
| 3839 | attrDecl = xmlHashLookup3(doc->extSubset->attributes, localName, |
| 3840 | prefix, elemname); |
| 3841 | if (attrDecl != NULL) |
| 3842 | extsubset = 1; |
| 3843 | } |
| 3844 | if ((elemname != buf) && (elemname != elem->name)) |
| 3845 | xmlFree(elemname); |
| 3846 | } |
| 3847 | if ((attrDecl == NULL) && (doc->intSubset != NULL)) |
| 3848 | attrDecl = xmlHashLookup3(doc->intSubset->attributes, localName, |
| 3849 | prefix, elem->name); |
| 3850 | if ((attrDecl == NULL) && (doc->extSubset != NULL)) { |
| 3851 | attrDecl = xmlHashLookup3(doc->extSubset->attributes, localName, |
| 3852 | prefix, elem->name); |
| 3853 | if (attrDecl != NULL) |
| 3854 | extsubset = 1; |
| 3855 | } |
| 3856 | |
| 3857 | if (attrDecl == NULL) |
| 3858 | goto done; |
| 3859 | if (attrDecl->atype == XML_ATTRIBUTE_CDATA) |
| 3860 | goto done; |
| 3861 | |
| 3862 | ret = xmlStrdup(value); |
| 3863 | if (ret == NULL) |
| 3864 | goto mem_error; |
| 3865 | xmlValidNormalizeString(ret); |
| 3866 | if ((doc->standalone) && (extsubset == 1) && (!xmlStrEqual(value, ret))) { |
| 3867 | xmlErrValidNode(ctxt, elem, XML_DTD_NOT_STANDALONE, |
no test coverage detected