I'm pretty sure the problem here is that you can't put an H1 element inside an SVG element (see
http://www.w3.org/TR/SVG/struct.html#SVGElement). You could try placing the H1 element immediately before the SVG element, or dispense with the H1 and add the ID attribute directly to the SVG element (depending on how you're generating the TOC).