Note that there are some explanatory texts on larger screens.

plurals
  1. POControl newlines in XML formatting with Grails render command
    primarykey
    data
    text
    <p>For most of our REST services, we are using the automatic marshalling of XML to output our results. Our testing group is reporting that they are getting unexpected new lines in the results (see below). I believe that these two results are equivalent considering that the only difference is ignorable whitespace and that testing should be parsing the results as XML and not doing string comparisons. Regardless, my personal preference would be to render the cleaner tighter version of the XML that testing wants, but my practical side says leave it alone.</p> <p>I've done some digging into the Grails <a href="http://grails.org/doc/latest/ref/Controllers/render.html" rel="nofollow">render</a> command, but don't see any way of controlling this output. I would expect that there would be something that we could setup in Config.groovy to control this as well, but I can't find anything there either. Any suggestions?</p> <p>We are getting:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;profile id="45"&gt; &lt;management id="6"/&gt; &lt;name&gt; TESTING_MGT_DOC &lt;/name&gt; &lt;type&gt; MGT &lt;/type&gt; &lt;user id="43"/&gt; &lt;/profile&gt; </code></pre> <p>Testing is expecting:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;profile id="45"&gt; &lt;management id="6"/&gt; &lt;name&gt;TESTING_MGT_DOC&lt;/name&gt; &lt;type&gt;MGT&lt;/type&gt; &lt;user id="43"/&gt; &lt;/profile&gt; </code></pre> <p>We are producing these results from a simple, one-line call in our controller.</p> <p>From ProfileController.groovy</p> <pre><code>... if(param.name){ render profileService.getProfileByName(param.name) as XML } ... </code></pre> <p>From ProfileService.groovy</p> <pre><code>... def getProfileByName(def name){ return Profile.findByProfileName(name) } ... </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload