67 questions
0
votes
1
answer
72
views
Groovy Sql resultSet rendering to XML via MarkupBuilder
I am trying to generate XML output in Groovy (4.0.18) from generic SQL requests where the query is provided at runtime.
So I have captured the SQL results in a List (of ResultSets) and I captured the ...
1
vote
1
answer
34
views
MarkupBuilder - Generate attributes without encapsulation
Is it possible to generate attributes using MarkupBuilder() without encapsulating it. I have the following:
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
// generate strings ...
0
votes
1
answer
84
views
Groovy Markup-Builder use dynamic node name
I want to create a XML with the Markup-Builder in Groovy. I have the following XML in my program:
<root>
<row>
<first-name>Max</first-name>
<last-name>...
1
vote
0
answers
101
views
Groovy throws error when "_-"are being used before root node while generating XML using XML markup builder .How to resolve it
While generating an XML from JSON I need to use "_-"before root node name due to naming convention rules but MarkupBuilder throws an error in groovy scripting. How can I resolve it?
input is ...
1
vote
1
answer
61
views
passing in args to a Closure for a StreamingMarkupBuilder
Groovy 2.4, Spring 5.3.13
Not having much luck using StreamingMarkupBuilder to create some XML, serialize it and print it
public void createMsgToStreamOut( String strCreatedAt, String strEntity, ...
0
votes
1
answer
217
views
Create XML object with dynamical content from a source CSV file
I have the following CSV file:
iDocType,iDocId,iName,iDate
P,555551555,Braiden,2022-12-31
I,100000001,Dominique,2024-12-10
P,100000002,Joyce,2025-11-15
Using jmeter's JSR223 preprocessor element, I ...
1
vote
1
answer
972
views
Using Groovy markupbuilder to build simple web page. No such DSL method 'body' found among steps
I am trying to build a simple webpage using HTML markup but I get the error: java.lang.NoSuchMethodError: No such DSL method 'body' found among steps
Code:
@NonCPS
def parseJsonForXml(inputJson) {
try ...
0
votes
1
answer
902
views
Iterate over Json map, create html table with embedded links
I'm reviewing an XML markupbuilder script that iterates through a json array (data from which is pulled from an external api) and displays the data in as an HTML table as follows:
import groovy.json....
2
votes
1
answer
685
views
Generate CDATA in XML using groovy MarkupBuilder
I want to be able to generate a CDATA portion in my XML using Groovy. I have used the mkp of the MarkupBuilder to do that, but it's not working. I am looping through products and then generate the ...
0
votes
1
answer
610
views
How to convince groovy.xml.MarkupBuilder to create a node whose name is 'use'
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 ...
0
votes
1
answer
48
views
how to create Gsp tag by Markupbuilder?
I want to create a gsp file like this:
but I fail to find how to write the code by markupbuilder.
my code like this:
MarkupBuilder mb = new groovy.xml.MarkupBuilder(strXml);
def ...
1
vote
1
answer
183
views
Using a taglib tag with MarkupBuilder
I try to call a Grails Tablib in combination with the Groovy MarkupBuilber
MarkupBuilder html = new MarkupBuilder(out)
html.div {
g.link(controller: "...", action: "...") {
...
}
}
...
0
votes
1
answer
83
views
Groovy MarkUpBuilder with local files
Im little stuck with XML. Path in sqlfile in XML must be taken from folders where are SQLfiles loaded by using dir and dir1 I have problem to build XML like that :
<databaseChangeLog
<...
0
votes
1
answer
192
views
why groovy each function not iterating while inside another one
why groovy .each function is only one time iterating while it lies inside another one iteration like shown below code ?
Code:
@Grab('com.xlson.groovycsv:groovycsv:1.1')
import static com.xlson....
0
votes
0
answers
193
views
why xml node attributes order changes after parsing with XmlSlurper?
The order of the attributes changes of using XmlSlurper.
Why it changes ?
We know that it doesn't affect the xml grammar. Even Is there any methods to keep the order as it is (or) Is there any ...
0
votes
1
answer
97
views
How to print plain content at the end of node using groovy MarkupBuilder?
I'm trying to implement a simple breadcrump in grails. I'm using taglib + Groovy MarkupBuilder. I'm use font-awesome too.
So, my problem is I want to put the text 'PROBLEM' after the icon. My code ...
0
votes
1
answer
930
views
add some declaration line to the xml file with the aid of MarkupBuilder
I am trying to build a xml file with the MarkupBuilder with some declarations and tags but I do not find a solution to build the following line
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx=...
1
vote
1
answer
193
views
call function during xml traversal in groovy
I transform one xml to another and I am not able to call function defined on script level from closure which used to process node from input xml.
See example code
def xml = new MarkupBuilder()
def ...
4
votes
2
answers
1k
views
Want Groovy MarkupBuilder() Equivalent to JSONBuilder() for Objects
Goal:
Given the myInfoObject definition below, I wish to be able to do this:
println new groovy.xml.MarkupBuilder(myInfoObject).toPrettyString()
Premise:
The following is one of the most amazing and ...
1
vote
0
answers
751
views
Refactoring groovy html markupbuilder
I picked up groovy scripting recently so I'm still a beginner in it
(I'm also a professional programmer in C with some notions of Java)
I successfully created a valid html page with the MarkupBuilder ...
1
vote
1
answer
2k
views
create xml markupBuilder based on external variables
I have seen in plenty of websites the common use of MarkupBuilder xml creator. For example:
def xmlWriter = new StringWriter()
def xmlMarkup = new MarkupBuilder(xmlWriter)
xmlMarkup.movie(id: "2", "...
0
votes
2
answers
532
views
How to add 
 after text in XML element in Groovy MarkupBuilder
Basically we are changing the datasource XML for an InDesign project the way the old. We don't want to change the InDesign so I have to adapt the new XML from the new datasource (a SOAP webservice via ...
0
votes
1
answer
415
views
groovy markup java.lang.Exception: No method named issue
Good day.
I am working on this groovy script
import groovy.xml.MarkupBuilder;
import groovy.xml.*;
def writer = new StringWriter();
def xmlResponse = new MarkupBuilder(writer);
def index = 0;
...
1
vote
2
answers
270
views
XML marshalling of nested elements in Grails using Groovy markup builder syntax
Grails: v2.5.0
How can I generate XML including nested elements without attributes?
This is my desired output:
<?xml version="1.0" encoding="UTF-8"?>
<list>
<book>
<title&...
0
votes
1
answer
146
views
How to format data in when defining XML in groovy?
I'm quite new to Groovy and couldn't find the right way to format/edit data in groovy when defining xml. I'd like to format my date to some custom format but I can't call any method from inside this ...
0
votes
1
answer
106
views
Create XML based on class hierarchy
My code is as follows:
class GlobalInfo {
// multiple properties here
String name;
GlobalInfo parent;
static hasMany = [children: GlobalInfo]
}
class RegionalInfo extends GlobalInfo {...
0
votes
2
answers
693
views
Unable to iterate JSON map using Groovy on Mule payload
I have trouble iterating the JSON (map) in my Groovy script, here's the details to my question.
In Mule I am receiving a JSON. Here it is :
{
"order": {
"ContactId": "112",
"...
0
votes
0
answers
294
views
Groovy StreamingMarkupBuilder:: Evaluate before bind
I am generating XML using StreamingMarkupBuilder.
I am trying to account for scenarios were there are errors in my data, resulting in NullPointerException. This is how my data is built up currently:
...
3
votes
1
answer
1k
views
How to add nodes under to different parents in Groovy Markup Builder by calling a method or closure
I would like to produce below xml.
I do not want to add xsv block inside xpm and MyRoot by repeating the same code.Instead I want to call a method or closure so that It will return xsv block which can ...
0
votes
0
answers
93
views
Only print opening in Groovy MarkupBuilder
I have code like the following
public String printHeader(){
println "<html><head>...</head><body><table>"
}
public String doMiddleStuff(blahblah){
println <...
2
votes
1
answer
2k
views
Groovy MarkupBuilder - not yielding raw text
I have the following chunk of code for writing out a series of button elements, containing an icon and text:
def tagcloud = { attrs, body ->
def mb = new MarkupBuilder(out)
mb.ul('class':...
1
vote
1
answer
532
views
Groovy MarkupBuilder passing string by reference
Doing transformation of a JSON feed to a format that can be consumed by our Endeca Instance, and settled on writing this transformation in Groovy, due to tools like JsonSlurper and MarkupBuilder. Our ...
0
votes
3
answers
2k
views
Groovy MarkupBuilder
I have a list of things, each of which might be a foo or a bar. I want to build some xml that looks like this:
<rdf:RDF>
<foo id="1">
<foo id="2">
<bar id="3">
</rdf:...
2
votes
1
answer
2k
views
Calling a method from inside StreamingMarkupBuilder
I'm using Groovy's StreamingMarkupBuilder to generate XML dynamically based on the results of a few SQL queries. I'd like to call a method from inside of the closure but the markup builder tries to ...
0
votes
1
answer
2k
views
Using external string variable with Groovy Markup Builder
I have created a string variable using some logic in groovy which reflects the braket syntax in markup builder but the problem is that you are obviously not allowed to use this string in markup ...
0
votes
1
answer
1k
views
Groovy markup builder replace the root
import groovy.xml.MarkupBuilder
class XmlTest {
static void main(def args) {
def XmlTest s = new XmlTest()
s.xmlTest()
}
def xmlTest() {
def xml = new ...
2
votes
2
answers
1k
views
Why does StreamingMarkupBuilder perform better than MarkupBuilder for writing large documents
I've read in several places that StreamingMarkupBuilder is better suited to writing large XML documents than MarkupBuilder. However, I've been unable to find a definitive answer as to why that is.
...
1
vote
1
answer
785
views
Groovy markupBuilder updating parent node
I'm building xml using MarkupBuilder and wonder how can I update a parent attribute when creating a child node. Assuming the number of child elements cannot be calculated when building the parent ...
12
votes
2
answers
14k
views
Adding multiple XML elements/containers dynamically using XML MarkupBuilder in Groovy
I am trying to generate XML using Groovy MarkupBuilder.
XML needed is of this form (simplified):
<Order>
<StoreID />
<City />
<Items>
<Item>
<...
1
vote
1
answer
1k
views
StreamingMarkupBuilder.out evaluates 'it' as a namespace prefix
I'm trying to generate a pom from custom Artifact groovy class using the following code:
def outputBuilder = new StreamingMarkupBuilder()
List<Artifact> artifacts = []
artifacts <&...
1
vote
1
answer
2k
views
groovy-wslite markupbuilder weired namespacing issue in soap-client
please help, i have a problem with the markupbuilder with groovy.
WORKING SOAP REQUEST against endpoint MYENDPOINT and the action MYACTION:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap....
-1
votes
1
answer
2k
views
Groovy. Appending nodes while using MarkupBuilder and XMLSlurper
My question is with Groovy and appending a node while using MarkupBuilder and XMLSlurper.
Can someone tell me why when I run this code up to the first println my output shows the target-line as:
<...
7
votes
2
answers
7k
views
How to use Groovy XML MarkupBuilder to create valid HTML script tags?
I am using Groovy 1.8 XML MarkupBuilder to build an HTML page which includes a <script> tag.
When I load the page in Firefox 18 I see a blank page instead of the expected results.
This seems ...
2
votes
2
answers
2k
views
Groovy's MarkupBuilder exception on generating "id" XML tag
I'm trying to construct a XML feed, and Groovy's MarkupBuilder is giving me headaches:
def newsstandFeed(def id) {
def publication = Publication.get(id)
def issues = issueService....
1
vote
2
answers
5k
views
Generating nested XML using MarkupBuilder or StreamingMarkupBuilder
I've got a grouped query that results in a list of clinics. Within the clinics are patients. And within the patients are prescriptions. I'm trying to output this structure using MarkupBuilder, but ...
3
votes
1
answer
4k
views
Groovy: copy XML elements from one doc to another
I am new to Groovy and am stuck with a simple problem. All I wanna do is extract certain elements from one XML file and created a new file with it. Here's an example XML, let's use a Maven pom file:
&...
11
votes
1
answer
7k
views
Adding dynamic elements and attributes to groovy MarkupBuilder or StreamingMarkupBuilder [closed]
I've seen many example using Groovy's MarkupBuilder for building an XML document, but they all seem to use static attributes for every element in the document (the attribute names are all known at ...
5
votes
1
answer
2k
views
Groovy MarkupBuilder name conflict
I have this code:
String buildCatalog(Catalog catalog) {
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
xml.catalog(xmlns:'http://www.sybrium.com/XMLSchema/...
2
votes
1
answer
524
views
Creating <use> tag with StreamingMarkupBuilder
I am using StreamingMarkupBuilder to produce XML and I need to have a tag. Unfortunately I get exception :
Caught: java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to java.lang....
0
votes
1
answer
5k
views
How do I quickly print a groovy.util.slurpersupport.Node?
Is there an easy way to convert a groovy.util.slurpersupport.Node to a groovy.util.Node?
I am trying to use the XmlNodePrinter on a node coming from an XmlSlurper, for some quick debugging. Here is ...