Example #1
0
scew_attribute*
attribute_create(XML_Char const* name, XML_Char const* value)
{
    scew_attribute* attribute = NULL;

    assert(name != NULL);
    assert(value != NULL);

    attribute = (scew_attribute*) calloc(1, sizeof(scew_attribute));
    if (attribute == NULL)
    {
        set_last_error(scew_error_no_memory);
        return NULL;
    }
    attribute->name = scew_strdup(name);
    attribute->value = scew_strdup(value);

    return attribute;
}
Example #2
0
XML_Char const*
scew_element_set_contents(scew_element* element, XML_Char const* data)
{
    assert(element != NULL);
    assert(data != NULL);

    free(element->contents);
    element->contents = scew_strdup(data);

    return element->contents;
}
Example #3
0
XML_Char const*
scew_element_set_name(scew_element* element, XML_Char const* name)
{
    assert(element != NULL);
    assert(name != NULL);

    free(element->name);
    element->name = scew_strdup(name);

    return element->name;
}
Example #4
0
scew_element*
scew_element_create(XML_Char const* name)
{
    scew_element* element = NULL;

    assert(name != NULL);

    element = (scew_element*) calloc(1, sizeof(scew_element));
    if (element != NULL)
    {
        element->name = scew_strdup(name);
        element->attributes = attribute_list_create();
    }
    else
    {
        set_last_error(scew_error_no_memory);
    }

    return element;
}
Example #5
0
XML_Char const*
scew_attribute_set_value (scew_attribute *attribute, XML_Char const *value)
{
  XML_Char *new_value = NULL;

  assert (attribute != NULL);
  assert (value != NULL);

  new_value = scew_strdup (value);
  if (new_value != NULL)
    {
      free (attribute->value);
      attribute->value = new_value;
    }
  else
    {
      scew_error_set_last_error_ (scew_error_no_memory);
    }

  return new_value;
}
Example #6
0
XML_Char const*
scew_attribute_set_name (scew_attribute *attribute, XML_Char const *name)
{
  XML_Char *new_name = NULL;

  assert (attribute != NULL);
  assert (name != NULL);

  new_name = scew_strdup (name);
  if (new_name != NULL)
    {
      free (attribute->name);
      attribute->name = new_name;
    }
  else
    {
      scew_error_set_last_error_ (scew_error_no_memory);
    }

  return new_name;
}