Given a DOM node, grab its top-level Style nodes, convert every one into a SVG style dictionary, put them in a master dictionary of the form

        #style ID -> SVG style dictionary,

    and return the result.

    The possible keys and values of each SVG style dictionary, the style options, are

    - ``iconUrl``: URL of icon
    - ``stroke``: stroke color; RGB hex string
    - ``stroke-opacity``: stroke opacity
    - ``stroke-width``:  stroke width in pixels
    - ``fill``: fill color; RGB hex string
    - ``fill-opacity``: fill opacity

def build_svg_style(node):
    """
    Given a DOM node, grab its top-level Style nodes, convert every one into a SVG style dictionary, put them in a master dictionary of the form

        #style ID -> SVG style dictionary,

    and return the result.

    The possible keys and values of each SVG style dictionary, the style options, are

    - ``iconUrl``: URL of icon
    - ``stroke``: stroke color; RGB hex string
    - ``stroke-opacity``: stroke opacity
    - ``stroke-width``:  stroke width in pixels
    - ``fill``: fill color; RGB hex string
    - ``fill-opacity``: fill opacity
    """
    d = {}
    for item in get(node, 'Style'):
        style_id = '#' + attr(item, 'id')
        # Create style properties
        props = {}
        for x in get(item, 'PolyStyle'):
            color = val(get1(x, 'color'))
            if color:
                rgb, opacity = build_rgb_and_opacity(color)
                props['fill'] = rgb
                props['fill-opacity'] = opacity
                # Set default border style
                props['stroke'] = rgb
                props['stroke-opacity'] = opacity
                props['stroke-width'] = 1
            fill = valf(get1(x, 'fill'))
            if fill == 0:
                props['fill-opacity'] = fill
            elif fill == 1 and 'fill-opacity' not in props:
                props['fill-opacity'] = fill
            outline = valf(get1(x, 'outline'))
            if outline == 0:
                props['stroke-opacity'] = outline
            elif outline == 1 and 'stroke-opacity' not in props:
                props['stroke-opacity'] = outline
        for x in get(item, 'LineStyle'):
            color = val(get1(x, 'color'))
            if color:
                rgb, opacity = build_rgb_and_opacity(color)
                props['stroke'] = rgb
                props['stroke-opacity'] = opacity
            width = valf(get1(x, 'width'))
            if width is not None:
                props['stroke-width'] = width
        for x in get(item, 'IconStyle'):
            icon = get1(x, 'Icon')
            if not icon:
                continue
            # Clear previous style properties
            props = {}
            props['iconUrl'] = val(get1(icon, 'href'))

        d[style_id] = props

    return d