COPY (
    SELECT text '<?xml version="1.0" encoding="UTF-8" ?>' ||
        '<svg xmlns="http://www.w3.org/2000/svg">'

    UNION ALL
    SELECT '<g id="border">' || string_agg('<path d="' ||
        ST_AsSVG(ST_Transform(the_geom, 3005),
            maxdecimaldigits := 0) || '"/>', '') || '</g>'
    FROM hoge.bc_border

    UNION ALL
    SELECT '<g id="hospitals">' || string_agg('<ellipse ' ||
        ST_AsSVG(the_geom,
            maxdecimaldigits := 0) || '/>', '') || '</g>'
    FROM hoge.bc_hospitals

    UNION ALL
    SELECT '<g id="municipality">' || string_agg('<path d="' ||
        ST_AsSVG(the_geom,
            maxdecimaldigits := 0) || '"/>', '') || '</g>'
    FROM hoge.bc_municipality
    
    UNION ALL
    SELECT '<g id="pubs">' || string_agg('<ellipse ' ||
        ST_AsSVG(the_geom,
            maxdecimaldigits := 0) || '/>', '') || '</g>'
    FROM hoge.bc_pubs

    UNION ALL
    SELECT '<g id="voting_areas">' || string_agg('<path d="' ||
        ST_AsSVG(the_geom,
            maxdecimaldigits := 0) || '"/>', '') || '</g>'
    FROM hoge.bc_voting_areas

    UNION ALL
    SELECT '</svg>'
) TO 'R:/test.svg';