Beispiel #1
0
/* Creates and returns a new attribute with the same name and
   values as ORIG. */
struct attribute *
attribute_clone (const struct attribute *orig)
{
  struct attribute *attr;
  size_t i;

  attr = attribute_create (orig->name);
  for (i = 0; i < orig->n_values; i++)
    attribute_add_value (attr, orig->values[i]);
  return attr;
}
Beispiel #2
0
/**
 * Convert an annotation to an HTML attribute via css rules
 * @param xml_name the xml name of the property
 * @param a the annotation to convert
 * @param css_rules the css rules to use for transformation
 * @return a shiny new attribute or NULL if we failed
 */
attribute *annotation_to_attribute( annotation *a, char *xml_name, hashmap *css_rules )
{
    css_rule *rule = hashmap_get( css_rules, xml_name );
    if ( rule != NULL )
    {
        css_property *prop = css_rule_get_property( rule, a->name );
        if ( prop != NULL )
        {
            char *html_name = css_property_get_html_name( prop );
            //warning("annotation: creating attribute %s:%s\n",html_name,a->value);            
            return attribute_create( html_name, annotation_get_name(a), a->value );
        }
        // ignore this
        //else
        //    warning("annotation: failed to find property for %s:%s:%s\n",
        //        xml_name,a->name,a->value);
    }
    else
    {
        printf("annotation: failed to find css rule %s\n",xml_name);
    }
    return NULL;
}