Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting xml parser features not possible #41

Open
davecramer opened this issue Jan 20, 2015 · 3 comments
Open

setting xml parser features not possible #41

davecramer opened this issue Jan 20, 2015 · 3 comments

Comments

@davecramer
Copy link

Using groovy 2.3.7 I get the following error when parsing an xml file with a DOCTYPE

DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true

Is there a way to set the parser features ?

@andrhahn
Copy link

andrhahn commented Mar 6, 2015

I am encountering this issue too. Any workarounds?

@stevesaliman
Copy link

I'm also getting this with Groovy 2.3.9. This will be a show stopper for anyone trying to use http builder in Gradle 2.x plugins.

@stevesaliman
Copy link

I figured out a a workaround for this issue. I had to replace the default XML parser with one that can handle the doctype in an XML file. The following code should do the trick:

restClient.parser.'application/xml' = { response ->
  def slurper = new XmlSlurper(false, false)
  slurper.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false)
  return slurper.parse(response.entity.content)
}

In my case, restParser is an instance of RESTClient, but I think that instances of HTTPBuilder would work the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants