You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2015/09/06 12:12:45 UTC
[jira] [Commented] (GROOVY-7576) NamespaceBuilder does not add
namespace declaration to the generated xml
[ https://issues.apache.org/jira/browse/GROOVY-7576?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14732335#comment-14732335 ]
Paul King commented on GROOVY-7576:
-----------------------------------
Looks like a regression in {{MarkupBuilder}} that will need further investigation. It certainly worked in the past, e.g. see GROOVY-3282 but doesn't seem to work now, so I guess we don't have anything quite like that in our test suite.
In the meantime you could use NodeBuilder, e.g.:
{code}
import groovy.xml.XmlUtil
import groovy.xml.NamespaceBuilder
def writer = new StringWriter()
def builder = NodeBuilder.newInstance()
def xsd = new NamespaceBuilder(builder).namespace('http://www.w3.org/2001/XMLSchema', 'xs')
def root = xsd.schema() {}
println XmlUtil.serialize(root)
root = xsd.schema("xmlns:xs": 'http://www.w3.org/2001/XMLSchema') {}
println XmlUtil.serialize(root)
{code}
> NamespaceBuilder does not add namespace declaration to the generated xml
> ------------------------------------------------------------------------
>
> Key: GROOVY-7576
> URL: https://issues.apache.org/jira/browse/GROOVY-7576
> Project: Groovy
> Issue Type: Bug
> Components: XML Processing
> Affects Versions: 2.4.4
> Reporter: Zsolt Kovacs
> Assignee: Paul King
> Priority: Minor
>
> The code bellow produces the same XSD, both without the xmlns:xs attribute. It was tested in groovy console today:
> https://groovyconsole.appspot.com/edit/5161363399770112
> {code}
> import groovy.xml.MarkupBuilder
> import groovy.xml.NamespaceBuilder
> def writer = new StringWriter()
> def builder = new MarkupBuilder(writer)
> def xsd = new NamespaceBuilder(builder).namespace('http://www.w3.org/2001/XMLSchema', 'xs')
> xsd.schema() {}
> writer.toString()
> xsd.schema("xmlns:xs": 'http://www.w3.org/2001/XMLSchema') {}
> writer.toString()
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)