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

Function xmlSchemaGetCanonValue

ThirdParty/libxml2/vtklibxml2/xmlschemastypes.c:5879–6197  ·  view source on GitHub ↗

* xmlSchemaGetCanonValue: * @val: the precomputed value * @retValue: the returned value * * Get the canonical lexical representation of the value. * The caller has to FREE the returned retValue. * * WARNING: Some value types are not supported yet, resulting * in a @retValue of "???". * * TODO: XML Schema 1.0 does not define canonical representations * for: duration, gYearMonth, gYear, g

Source from the content-addressed store, hash-verified

5877 * not supported yet and -1 in case of API errors.
5878 */
5879int
5880xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
5881{
5882 if ((retValue == NULL) || (val == NULL))
5883 return (-1);
5884 *retValue = NULL;
5885 switch (val->type) {
5886 case XML_SCHEMAS_STRING:
5887 if (val->value.str == NULL)
5888 *retValue = BAD_CAST xmlStrdup(BAD_CAST "");
5889 else
5890 *retValue =
5891 BAD_CAST xmlStrdup((const xmlChar *) val->value.str);
5892 break;
5893 case XML_SCHEMAS_NORMSTRING:
5894 if (val->value.str == NULL)
5895 *retValue = BAD_CAST xmlStrdup(BAD_CAST "");
5896 else {
5897 *retValue = xmlSchemaWhiteSpaceReplace(
5898 (const xmlChar *) val->value.str);
5899 if ((*retValue) == NULL)
5900 *retValue = BAD_CAST xmlStrdup(
5901 (const xmlChar *) val->value.str);
5902 }
5903 break;
5904 case XML_SCHEMAS_TOKEN:
5905 case XML_SCHEMAS_LANGUAGE:
5906 case XML_SCHEMAS_NMTOKEN:
5907 case XML_SCHEMAS_NAME:
5908 case XML_SCHEMAS_NCNAME:
5909 case XML_SCHEMAS_ID:
5910 case XML_SCHEMAS_IDREF:
5911 case XML_SCHEMAS_ENTITY:
5912 case XML_SCHEMAS_NOTATION: /* Unclear */
5913 case XML_SCHEMAS_ANYURI: /* Unclear */
5914 if (val->value.str == NULL)
5915 return (-1);
5916 *retValue =
5917 BAD_CAST xmlSchemaCollapseString(BAD_CAST val->value.str);
5918 if (*retValue == NULL)
5919 *retValue =
5920 BAD_CAST xmlStrdup((const xmlChar *) val->value.str);
5921 break;
5922 case XML_SCHEMAS_QNAME:
5923 /* TODO: Unclear in XML Schema 1.0. */
5924 if (val->value.qname.uri == NULL) {
5925 *retValue = BAD_CAST xmlStrdup(BAD_CAST val->value.qname.name);
5926 return (0);
5927 } else {
5928 *retValue = BAD_CAST xmlStrdup(BAD_CAST "{");
5929 *retValue = BAD_CAST xmlStrcat((xmlChar *) (*retValue),
5930 BAD_CAST val->value.qname.uri);
5931 *retValue = BAD_CAST xmlStrcat((xmlChar *) (*retValue),
5932 BAD_CAST "}");
5933 *retValue = BAD_CAST xmlStrcat((xmlChar *) (*retValue),
5934 BAD_CAST val->value.qname.uri);
5935 }
5936 break;

Callers 2

Calls 6

xmlStrdupFunction · 0.85
xmlSchemaCollapseStringFunction · 0.85
xmlStrcatFunction · 0.85
xmlSchemaDateNormalizeFunction · 0.85
xmlSchemaFreeValueFunction · 0.85

Tested by

no test coverage detected