Open GoogleCodeExporter opened 8 years ago
In fact, the following change in StaxXMLWriter2 fixes the problem:
public StaxXMLWriter2(Writer stream) {
XMLOutputFactory f = new WstxOutputFactory();
f.setProperty(WstxOutputFactory.P_AUTOMATIC_EMPTY_ELEMENTS,true);
and adding this to pom.xml:
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>wstx-asl</artifactId>
<version>4.0.6</version>
</dependency>
Somehow this makes unit tests fail, but at least this unblocks me.
Original comment by oleg.du...@gmail.com
on 28 Feb 2013 at 2:36
An alternative to adding a new build dependency is to insert this code into
MetadataResource.java:
// inside getMetadata()
return Response.ok(makeMetadataCompatibleWithDotNet(w.toString()), ODataConstants.APPLICATION_XML_CHARSET_UTF8)
.header(ODataConstants.Headers.DATA_SERVICE_VERSION, ODataConstants.DATA_SERVICE_VERSION_HEADER)
.build();
// new method
private String makeMetadataCompatibleWithDotNet(final String originalMetadataText) {
// convert tags to be compatible with .NET: <PropertyRef ...></PropertyRef> --> <PropertyRef .../>
final Pattern pattern = Pattern.compile("<(\\w+)\\s+([^>]+)>\\s*</\\1>");
final Matcher matcher = pattern.matcher(originalMetadataText);
StringBuffer sb = new StringBuffer(originalMetadataText.length());
int lastIndex = 0;
while (matcher.find()) {
sb.append(originalMetadataText.substring(lastIndex, matcher.start()));
sb.append('<').append(matcher.group(1)).append(' ').append(matcher.group(2)).append("/>");
lastIndex = matcher.end();
}
sb.append(originalMetadataText.substring(lastIndex));
return sb.toString();
}
Original comment by rndg...@gmail.com
on 30 Aug 2013 at 4:30
Original issue reported on code.google.com by
oleg.du...@gmail.com
on 28 Feb 2013 at 12:50Attachments: