Beispiel #1
0
int
xps_parse_resource_dictionary(xps_context *ctx, xps_resource **dictp, char *base_uri, xml_element *root)
{
	xps_resource *head;
	xps_resource *entry;
	xml_element *node;
	char *source;
	char *key;
	int code;

	source = xml_att(root, "Source");
	if (source)
	{
		code = xps_parse_remote_resource_dictionary(ctx, dictp, base_uri, source);
		if (code)
			return fz_rethrow(code, "cannot parse remote resource dictionary");
		return fz_okay;
	}

	head = NULL;

	for (node = xml_down(root); node; node = xml_next(node))
	{
		key = xml_att(node, "x:Key");
		if (key)
		{
			entry = fz_malloc(sizeof(xps_resource));
			entry->name = key;
			entry->base_uri = NULL;
			entry->base_xml = NULL;
			entry->data = node;
			entry->next = head;
			entry->parent = NULL;
			head = entry;
		}
	}

	if (head)
	{
		head->base_uri = fz_strdup(base_uri);
	}

	*dictp = head;
	return fz_okay;
}
Beispiel #2
0
xps_resource *
xps_parse_resource_dictionary(xps_document *doc, char *base_uri, xml_element *root)
{
	xps_resource *head;
	xps_resource *entry;
	xml_element *node;
	char *source;
	char *key;

	source = xml_att(root, "Source");
	if (source)
		return xps_parse_remote_resource_dictionary(doc, base_uri, source);

	head = NULL;

	for (node = xml_down(root); node; node = xml_next(node))
	{
		key = xml_att(node, "x:Key");
		if (key)
		{
			entry = fz_malloc_struct(doc->ctx, xps_resource);
			entry->name = key;
			entry->base_uri = NULL;
			entry->base_xml = NULL;
			entry->data = node;
			entry->next = head;
			entry->parent = NULL;
			head = entry;
		}
	}

	if (head)
		head->base_uri = fz_strdup(doc->ctx, base_uri);
	else
		fz_warn(doc->ctx, "empty resource dictionary");

	return head;
}
Beispiel #3
0
xps_resource *
xps_parse_resource_dictionary(fz_context *ctx, xps_document *doc, char *base_uri, fz_xml *root)
{
	xps_resource *head;
	xps_resource *entry;
	fz_xml *node;
	char *source;
	char *key;

	source = fz_xml_att(root, "Source");
	if (source)
		return xps_parse_remote_resource_dictionary(ctx, doc, base_uri, source);

	head = NULL;

	for (node = fz_xml_down(root); node; node = fz_xml_next(node))
	{
		key = fz_xml_att(node, "x:Key");
		if (key)
		{
			entry = fz_malloc_struct(ctx, xps_resource);
			entry->name = key;
			entry->base_uri = NULL;
			entry->base_xml = NULL;
			entry->data = node;
			entry->next = head;
			entry->parent = NULL;
			head = entry;
		}
	}

	if (head)
		head->base_uri = fz_strdup(ctx, base_uri);

	return head;
}