SVG defines an element named use and I am trying to generate an SVG file using groovy.xml.MarkupBuilder that takes advantage of this tag:
http://tutorials.jenkov.com/svg/defs-element.html
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
xml.svg {
defs {
g(id:"shape") {
rect(x:50, y:50, width:50, height:50)
circle(cx:50, cy:50, r:50)
}
}
use("xlink:href":"#shape", x:50, y:50")
}
However use is also a keyword in groovy. How do I escape it correctly?
not sure those methods are official however they work:
v1:
v2:
v3:
we could redefine
getNamemethod that is responsible to do names mapping or check escaping rules.