xml - How to use groovy XMLbuilder for attributes that have hyphens in the name -


I am using groovy and groovy.xml.MarkupBuilder to write a library that I use to create an API file Will do I am writing a function that can be used to generate the container.xml file and I found that my id gives me an error when I try to use an attribute name that contains a hyphen, when that There is no resistance to the name of its opposition, a hyphen

  def author = new stringwriter (); Def xml = new markup builder (author); Def fullPath = "full-path" def mediaType = "media-type" def generator container () {xml.xmlDeclaration () xml.container (version: '1.0', xmlns: 'color: oasis: name: tc: opendocument: xmlns : Container ') {root files {rootfile (it's complete:' OEBPS / content.opf ', this.mediaType:' application / oebps-package + xml ')}}}   

when I try to use

  full path   

I have given an error when I

  full path I try to use   

then it does not give me any errors.

Why does this happen and how can I do it right?

  View the full-path value (in bold) This is the only part of the file that will always be different.   

I want to be as accurate as possible

This works As expected:

  import groovy.xml.MarkupBuilder def author = new stringwriters (def) xml = new markup builder (author) def fullPath = "full-path" def mediaType = "media -type "xml.mkp.xmlDeclaration (version:" 1.0 ", encoding:" UTF-8 ") xml.container (version: '1.0', XMLLS: 'Color: Oasis: Name: TC: OpenDown: xmlns: Container' ) {Rootfile {rootfile (full path): 'OBPS / content. EFF ', (MediaType):' Application / OABS-package + XML ')} Print Linen Author   

Make sure that you are the variable fullpath To use the (full path) [braces], use the value of the variable as the attribute in the XML node.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -