| 2838 | } |
| 2839 | |
| 2840 | xmlNode *expand_idref(xmlNode *input, xmlNode *top) |
| 2841 | { |
| 2842 | const char *tag = NULL; |
| 2843 | const char *ref = NULL; |
| 2844 | xmlNode *result = input; |
| 2845 | char *xpath_string = NULL; |
| 2846 | |
| 2847 | if(result == NULL) { |
| 2848 | return NULL; |
| 2849 | |
| 2850 | } else if(top == NULL) { |
| 2851 | top = input; |
| 2852 | } |
| 2853 | |
| 2854 | tag = crm_element_name(result); |
| 2855 | ref = crm_element_value(result, XML_ATTR_IDREF); |
| 2856 | |
| 2857 | if(ref != NULL) { |
| 2858 | int xpath_max = 512, offset = 0; |
| 2859 | xpath_string = calloc(1, xpath_max); |
| 2860 | |
| 2861 | offset += snprintf(xpath_string + offset, xpath_max - offset, "//%s[@id='%s']", tag, ref); |
| 2862 | result = get_xpath_object(xpath_string, top, LOG_ERR); |
| 2863 | if(result == NULL) { |
| 2864 | char *nodePath = (char *)xmlGetNodePath(top); |
| 2865 | crm_err("No match for %s found in %s: Invalid configuration", xpath_string, crm_str(nodePath)); |
| 2866 | free(nodePath); |
| 2867 | } |
| 2868 | } |
| 2869 | |
| 2870 | free(xpath_string); |
| 2871 | return result; |
| 2872 | } |
| 2873 | |
| 2874 | xmlNode* |
| 2875 | get_xpath_object_relative(const char *xpath, xmlNode *xml_obj, int error_level) |