static void xps_parse_metadata_imp(fz_context *ctx, xps_document *doc, fz_xml *item, xps_fixdoc *fixdoc) { while (item) { if (fz_xml_is_tag(item, "Relationship")) { char *target = fz_xml_att(item, "Target"); char *type = fz_xml_att(item, "Type"); if (target && type) { char tgtbuf[1024]; xps_resolve_url(ctx, doc, tgtbuf, doc->base_uri, target, sizeof tgtbuf); if (!strcmp(type, REL_START_PART) || !strcmp(type, REL_START_PART_OXPS)) doc->start_part = fz_strdup(ctx, tgtbuf); if ((!strcmp(type, REL_DOC_STRUCTURE) || !strcmp(type, REL_DOC_STRUCTURE_OXPS)) && fixdoc) fixdoc->outline = fz_strdup(ctx, tgtbuf); if (!fz_xml_att(item, "Id")) fz_warn(ctx, "missing relationship id for %s", target); } } if (fz_xml_is_tag(item, "DocumentReference")) { char *source = fz_xml_att(item, "Source"); if (source) { char srcbuf[1024]; xps_resolve_url(ctx, doc, srcbuf, doc->base_uri, source, sizeof srcbuf); xps_add_fixed_document(ctx, doc, srcbuf); } } if (fz_xml_is_tag(item, "PageContent")) { char *source = fz_xml_att(item, "Source"); char *width_att = fz_xml_att(item, "Width"); char *height_att = fz_xml_att(item, "Height"); int width = width_att ? atoi(width_att) : 0; int height = height_att ? atoi(height_att) : 0; if (source) { char srcbuf[1024]; xps_resolve_url(ctx, doc, srcbuf, doc->base_uri, source, sizeof srcbuf); xps_add_fixed_page(ctx, doc, srcbuf, width, height); } } if (fz_xml_is_tag(item, "LinkTarget")) { char *name = fz_xml_att(item, "Name"); if (name) xps_add_link_target(ctx, doc, name); } xps_parse_metadata_imp(ctx, doc, fz_xml_down(item), fixdoc); item = fz_xml_next(item); } }
static void xps_parse_metadata_imp(xps_context *ctx, xml_element *item) { while (item) { xps_parse_metadata_imp(ctx, xml_down(item)); if (!strcmp(xml_tag(item), "Relationship")) { char *target = xml_att(item, "Target"); char *type = xml_att(item, "Type"); if (target && type) { char tgtbuf[1024]; xps_absolute_path(tgtbuf, ctx->base_uri, target, sizeof tgtbuf); if (!strcmp(type, REL_START_PART)) ctx->start_part = fz_strdup(tgtbuf); } } if (!strcmp(xml_tag(item), "DocumentReference")) { char *source = xml_att(item, "Source"); if (source) { char srcbuf[1024]; xps_absolute_path(srcbuf, ctx->base_uri, source, sizeof srcbuf); xps_add_fixed_document(ctx, srcbuf); } } if (!strcmp(xml_tag(item), "PageContent")) { char *source = xml_att(item, "Source"); char *width_att = xml_att(item, "Width"); char *height_att = xml_att(item, "Height"); int width = width_att ? atoi(width_att) : 0; int height = height_att ? atoi(height_att) : 0; if (source) { char srcbuf[1024]; xps_absolute_path(srcbuf, ctx->base_uri, source, sizeof srcbuf); xps_add_fixed_page(ctx, srcbuf, width, height); } } item = xml_next(item); } }
static void xps_parse_metadata_imp(void *zp, char *name, char **atts) { xps_context_t *ctx = zp; int i; if (!strcmp(name, "Relationship")) { char tgtbuf[1024]; char *target = NULL; char *type = NULL; for (i = 0; atts[i]; i += 2) { if (!strcmp(atts[i], "Target")) target = atts[i + 1]; if (!strcmp(atts[i], "Type")) type = atts[i + 1]; } if (target && type) { xps_absolute_path(tgtbuf, ctx->base_uri, target, sizeof tgtbuf); if (!strcmp(type, REL_START_PART)) ctx->start_part = xps_strdup(ctx, tgtbuf); } } if (!strcmp(name, "DocumentReference")) { char *source = NULL; char srcbuf[1024]; for (i = 0; atts[i]; i += 2) { if (!strcmp(atts[i], "Source")) source = atts[i + 1]; } if (source) { xps_absolute_path(srcbuf, ctx->base_uri, source, sizeof srcbuf); xps_add_fixed_document(ctx, srcbuf); } } if (!strcmp(name, "PageContent")) { char *source = NULL; char srcbuf[1024]; int width = 0; int height = 0; for (i = 0; atts[i]; i += 2) { if (!strcmp(atts[i], "Source")) source = atts[i + 1]; if (!strcmp(atts[i], "Width")) width = atoi(atts[i + 1]); if (!strcmp(atts[i], "Height")) height = atoi(atts[i + 1]); } if (source) { xps_absolute_path(srcbuf, ctx->base_uri, source, sizeof srcbuf); xps_add_fixed_page(ctx, srcbuf, width, height); } } }