Project

Profile

Help

Unwanted warning with JAXBSource

Added by Mark Thornton about 9 years ago

I am using a JAXBSource as the input for a transform and get the following message:

Selected XML parser javax.xml.bind.util.JAXBSource$1 does not recognize the feature http://xml.org/sax/features/validation

while correct, it clutters up my output. The transform itself works perfectly. Is there a way to turn off this message?

Using Saxon-HE 9.7.0-1 Java (OpenJDK) 8 Ubuntu 15.04


Replies (6)

Please register to reply

RE: Unwanted warning with JAXBSource - Added by O'Neil Delpratt about 9 years ago

Thank you for reporting the problem you have found. Currently investigating it.

RE: Unwanted warning with JAXBSource - Added by O'Neil Delpratt about 9 years ago

Hi Mark,

Is it possible for you please to send a repo either on the post or via private email. Thanks

RE: Unwanted warning with JAXBSource - Added by Mark Thornton about 9 years ago

Here you are



import java.io.StringReader;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.util.JAXBSource;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;


/** Test transforming with a JAXBSource
 *
 */
@XmlRootElement
public class TransformJAXBSource
{
	@XmlElement public String message;

	public static void main(String[] args) throws Exception
	{
		JAXBContext jaxbContext = JAXBContext.newInstance(TransformJAXBSource.class);
		TransformJAXBSource content = new TransformJAXBSource();
		content.message = "Hello";
		JAXBSource source = new JAXBSource(jaxbContext, content);
		TransformerFactory factory = TransformerFactory.newInstance();
		Source transformSource = new StreamSource(new StringReader(
			"" +
				"" +
				""
		));
		Transformer transformer = factory.newTransformer(transformSource);
		transformer.transform(source, new StreamResult(System.out));
	}
}

Output is

Selected XML parser javax.xml.bind.util.JAXBSource$1 does not recognize the feature http://xml.org/sax/features/validation
Hello

RE: Unwanted warning with JAXBSource - Added by Mark Thornton about 9 years ago

Or even shorter


import javax.xml.bind.JAXBContext;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.util.JAXBSource;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;


/** Test transforming with a JAXBSource
 *
 */
@XmlRootElement
public class TransformJAXBSource
{
	@XmlElement public String message;

	public static void main(String[] args) throws Exception
	{
		JAXBContext jaxbContext = JAXBContext.newInstance(TransformJAXBSource.class);
		TransformJAXBSource content = new TransformJAXBSource();
		content.message = "Hello";
		JAXBSource source = new JAXBSource(jaxbContext, content);
		TransformerFactory factory = TransformerFactory.newInstance();
		Transformer transformer = factory.newTransformer();
		transformer.transform(source, new StreamResult(System.out));
	}
}

with output

Selected XML parser javax.xml.bind.util.JAXBSource$1 does not recognize the feature http://xml.org/sax/features/validation
Hello

RE: Unwanted warning with JAXBSource - Added by O'Neil Delpratt about 9 years ago

Thanks for sending us the repo. I have managed to reproduce the error message. I have logged this against a bug which has been fixed. See bug issue #2540

RE: Unwanted warning with JAXBSource - Added by Mark Thornton about 9 years ago

Thank you for fixing it so promptly.

    (1-6/6)

    Please register to reply