class MicroSvgParser {

	static Group readSvg(InputStream in, DoubleProperty svgWidth, DoubleProperty svgHeight,
			ObjectProperty<Paint> svgFill) throws Exception {

		NodeList paths = (NodeList) XPathFactory.newDefaultInstance().newXPath().evaluate("/svg/g/path",
				DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in), XPathConstants.NODESET);

		Group group = new Group();
		for (int i = 0; i < paths.getLength(); i++) {
			NamedNodeMap attributes = paths.item(i).getAttributes();

			SVGPath path = new SVGPath();

			var fill = attributes.getNamedItem("fill");
			if (fill != null)
				path.setFill(fill.getTextContent().equals("none") ? Color.TRANSPARENT
						: Paint.valueOf(fill.getTextContent()));
			else if (svgFill.get() != null)
				path.setFill(svgFill.get());

			var fillRule = attributes.getNamedItem("fill-rule");
			if (fillRule != null)
				switch (fillRule.getTextContent()) {
				case "evenodd":
					path.setFillRule(FillRule.EVEN_ODD);
					break;
				case "nonzero":
					path.setFillRule(FillRule.NON_ZERO);
					break;
				default:
					log.warn("Unknown fill-rule: " + fillRule.getTextContent());
					break;
				}

			var d = attributes.getNamedItem("d");
			if (d != null)
				path.setContent(d.getTextContent());

			var style = attributes.getNamedItem("style");
			if (style != null)
				path.setStyle(style.getTextContent());

			group.getChildren().add(path);
		}

		group.scaleXProperty().bind(Bindings.divide(svgWidth, group.getBoundsInParent().getWidth()));
		group.scaleYProperty().bind(Bindings.divide(svgHeight, group.getBoundsInParent().getHeight()));

		return group;
	}

}