* xmlSchemaFormatItemForReport: * @buf: the string buffer * @itemDes: the designation of the item * @itemName: the name of the item * @item: the item as an object * @itemNode: the node of the item * @local: the local name * @parsing: if the function is used during the parse * * Returns a representation of the given item used * for error reports. * * The following order is used to build
| 1615 | * Returns the formatted string and sets @buf to the resulting value. |
| 1616 | */ |
| 1617 | static xmlChar* |
| 1618 | xmlSchemaFormatItemForReport(xmlChar **buf, |
| 1619 | const xmlChar *itemDes, |
| 1620 | xmlSchemaBasicItemPtr item, |
| 1621 | xmlNodePtr itemNode) |
| 1622 | { |
| 1623 | xmlChar *str = NULL; |
| 1624 | int named = 1; |
| 1625 | |
| 1626 | if (*buf != NULL) { |
| 1627 | xmlFree(*buf); |
| 1628 | *buf = NULL; |
| 1629 | } |
| 1630 | |
| 1631 | if (itemDes != NULL) { |
| 1632 | *buf = xmlStrdup(itemDes); |
| 1633 | } else if (item != NULL) { |
| 1634 | switch (item->type) { |
| 1635 | case XML_SCHEMA_TYPE_BASIC: { |
| 1636 | xmlSchemaTypePtr type = WXS_TYPE_CAST item; |
| 1637 | |
| 1638 | if (WXS_IS_ATOMIC(type)) |
| 1639 | *buf = xmlStrdup(BAD_CAST "atomic type 'xs:"); |
| 1640 | else if (WXS_IS_LIST(type)) |
| 1641 | *buf = xmlStrdup(BAD_CAST "list type 'xs:"); |
| 1642 | else if (WXS_IS_UNION(type)) |
| 1643 | *buf = xmlStrdup(BAD_CAST "union type 'xs:"); |
| 1644 | else |
| 1645 | *buf = xmlStrdup(BAD_CAST "simple type 'xs:"); |
| 1646 | *buf = xmlStrcat(*buf, type->name); |
| 1647 | *buf = xmlStrcat(*buf, BAD_CAST "'"); |
| 1648 | } |
| 1649 | break; |
| 1650 | case XML_SCHEMA_TYPE_SIMPLE: { |
| 1651 | xmlSchemaTypePtr type = WXS_TYPE_CAST item; |
| 1652 | |
| 1653 | if (type->flags & XML_SCHEMAS_TYPE_GLOBAL) { |
| 1654 | *buf = xmlStrdup(BAD_CAST""); |
| 1655 | } else { |
| 1656 | *buf = xmlStrdup(BAD_CAST "local "); |
| 1657 | } |
| 1658 | if (WXS_IS_ATOMIC(type)) |
| 1659 | *buf = xmlStrcat(*buf, BAD_CAST "atomic type"); |
| 1660 | else if (WXS_IS_LIST(type)) |
| 1661 | *buf = xmlStrcat(*buf, BAD_CAST "list type"); |
| 1662 | else if (WXS_IS_UNION(type)) |
| 1663 | *buf = xmlStrcat(*buf, BAD_CAST "union type"); |
| 1664 | else |
| 1665 | *buf = xmlStrcat(*buf, BAD_CAST "simple type"); |
| 1666 | if (type->flags & XML_SCHEMAS_TYPE_GLOBAL) { |
| 1667 | *buf = xmlStrcat(*buf, BAD_CAST " '"); |
| 1668 | *buf = xmlStrcat(*buf, type->name); |
| 1669 | *buf = xmlStrcat(*buf, BAD_CAST "'"); |
| 1670 | } |
| 1671 | } |
| 1672 | break; |
| 1673 | case XML_SCHEMA_TYPE_COMPLEX: { |
| 1674 | xmlSchemaTypePtr type = WXS_TYPE_CAST item; |
no test coverage detected