xps_open_device(gx_device *dev)
{
    gx_device_vector * vdev = (gx_device_vector*)dev;
    gx_device_xps * xps = (gx_device_xps*)dev;
    int code = 0;

    vdev->v_memory = dev->memory;
    vdev->vec_procs = &xps_vector_procs;
    gdev_vector_init(vdev);
    code = gdev_vector_open_file_options(vdev, 512,
        VECTOR_OPEN_FILE_SEQUENTIAL);
    if (code < 0)
      return gs_rethrow_code(code);

    /* In case ths device has been subclassed, descend to the terminal
     * of the chain. (Setting the variables in a subclassing device
     * doesn't do anythign useful.....)
     */
    while(vdev->child)
        vdev = (gx_device_vector *)vdev->child;
    xps = (gx_device_xps*)vdev;

    /* xps-specific initialization goes here */
    xps->page_count = 0;
    xps->relationship_count = 0;
    xps->strokecolor = gx_no_color_index;
    xps->fillcolor = gx_no_color_index;
    xps_setstrokebrush(xps, xps_solidbrush);
    xps_setfillbrush(xps, xps_solidbrush);
    /* these should be the graphics library defaults instead? */
    xps->linewidth = XPS_DEFAULT_LINEWIDTH;
    xps->linecap = XPS_DEFAULT_LINECAP;
    xps->linejoin = XPS_DEFAULT_LINEJOIN;
    xps->miterlimit = XPS_DEFAULT_MITERLIMIT;
    xps->can_stroke = true;
    /* zip info */
    xps->f2i = NULL;
    xps->f2i_tail = NULL;

    /* Image related stuff */
    xps->image_count = 0;
    xps->xps_pie = NULL;

    /* ICC related stuff */
    xps->icc_data = NULL;

    code = write_str_to_zip_file(xps, (char *)"FixedDocumentSequence.fdseq",
                                 fixed_document_sequence);
    if (code < 0)
        return gs_rethrow_code(code);
    
    code = write_str_to_zip_file(xps, (char *)"[Content_Types].xml",
                                 xps_content_types);
    if (code < 0)
        return gs_rethrow_code(code);

    code = write_str_to_zip_file(xps,
                                 (char *)"Documents/1/FixedDocument.fdoc",
                                 fixed_document_fdoc_header);
    if (code < 0)
        return gs_rethrow_code(code);

    /* Right out the magical stuff related to the fix document sequence relationship */
    code = write_str_to_zip_file(xps, (char *)"_rels/.rels", rels_header);
    if (code < 0)
        return gs_rethrow_code(code);

    code = write_str_to_zip_file(xps, (char *)"_rels/.rels", rels_fdseq);
    if (code < 0)
        return gs_rethrow_code(code);

    return code;
}
xps_open_device(gx_device *dev)
{
    gx_device_vector * vdev = (gx_device_vector*)dev;
    gx_device_xps * xps = (gx_device_xps*)dev;
    int code = 0;

    vdev->v_memory = dev->memory;
    vdev->vec_procs = &xps_vector_procs;
    gdev_vector_init(vdev);
    code = gdev_vector_open_file_options(vdev, 512,
        VECTOR_OPEN_FILE_SEQUENTIAL);
    if (code < 0)
      return gs_rethrow_code(code);

     
    while(vdev->child)
        vdev = (gx_device_vector *)vdev->child;
    xps = (gx_device_xps*)vdev;

     
    xps->page_count = 0;
    xps->relationship_count = 0;
    xps->strokecolor = gx_no_color_index;
    xps->fillcolor = gx_no_color_index;
    xps_setstrokebrush(xps, xps_solidbrush);
    xps_setfillbrush(xps, xps_solidbrush);
     
    xps->linewidth = XPS_DEFAULT_LINEWIDTH;
    xps->linecap = XPS_DEFAULT_LINECAP;
    xps->linejoin = XPS_DEFAULT_LINEJOIN;
    xps->miterlimit = XPS_DEFAULT_MITERLIMIT;
    xps->can_stroke = true;
     
    xps->f2i = NULL;
    xps->f2i_tail = NULL;

     
    xps->image_count = 0;
    xps->xps_pie = NULL;

     
    xps->icc_data = NULL;

    code = write_str_to_zip_file(xps, (char *)"FixedDocumentSequence.fdseq",
                                 fixed_document_sequence);
    if (code < 0)
        return gs_rethrow_code(code);
    
    code = write_str_to_zip_file(xps, (char *)"[Content_Types].xml",
                                 xps_content_types);
    if (code < 0)
        return gs_rethrow_code(code);

    code = write_str_to_zip_file(xps,
                                 (char *)"Documents/1/FixedDocument.fdoc",
                                 fixed_document_fdoc_header);
    if (code < 0)
        return gs_rethrow_code(code);

     
    code = write_str_to_zip_file(xps, (char *)"_rels/.rels", rels_header);
    if (code < 0)
        return gs_rethrow_code(code);

    code = write_str_to_zip_file(xps, (char *)"_rels/.rels", rels_fdseq);
    if (code < 0)
        return gs_rethrow_code(code);

    return code;
}