jaxp

JAXP XSLT transformer using wrong implementation by default

风格不统一 提交于 2019-12-23 10:28:11
问题 I've got a Tomcat 5.5 web application that uses the Apache Commons-Configuration library to generate an XML configuration file at runtime. Commons-Configuration, in turn, uses the javax.xml.transform JAXP API to accomplish this. Since upgrading to Java 7, the operation fails with the following error message: Caused by: javax.xml.transform.TransformerFactoryConfigurationError: Provider org.apache.xalan.processor.TransformerFactoryImpl not found at javax.xml.transform.TransformerFactory

Workaround for XMLSchema not supporting maxOccurs larger than 5000

大憨熊 提交于 2019-12-21 12:59:02
问题 My problem is with parsing an XSD Schema that has elements with maxOccurs larger than 5000 (but not unbounded ). This is actually a know issue in either Xerces (which I'm using, version 2.9.1) or JAXP, as described here: http://bugs.sun.com/view_bug.do;jsessionid=85335466c2c1fc52f0245d20b2e?bug_id=4990915 I already know that if I changed the maxOccurs numbers in my XSD from numbers larger than 5000 to unbounded all works well. Sadly, this is not an option in my case (I cannot meddle with the

jaxp object caching for MessageFactory

青春壹個敷衍的年華 提交于 2019-12-19 19:08:49
问题 Can the javax.xml.soap.MessageFactory be reused? I.e. msgFactory = MessageFactory.newInstance(); Can I cache msgFactory and reuse it to create new SOAPMessages as needed? Also should the msgFactory.createMessage(); be synchronized if it is ok to reuse msgFactory in the code? UPDATE: Also in single threaded-code, could I store msgFactory to create SOAPMessages over and over, so as not to create a new instance of MessageFactory each time Thanks 回答1: There's nothing in the javadoc to say that

jaxp object caching for MessageFactory

我的梦境 提交于 2019-12-19 19:04:12
问题 Can the javax.xml.soap.MessageFactory be reused? I.e. msgFactory = MessageFactory.newInstance(); Can I cache msgFactory and reuse it to create new SOAPMessages as needed? Also should the msgFactory.createMessage(); be synchronized if it is ok to reuse msgFactory in the code? UPDATE: Also in single threaded-code, could I store msgFactory to create SOAPMessages over and over, so as not to create a new instance of MessageFactory each time Thanks 回答1: There's nothing in the javadoc to say that

How to validate an XML document using a RELAX NG schema and JAXP?

女生的网名这么多〃 提交于 2019-12-18 12:16:58
问题 I would like to validate XML documents using RELAX NG schemata, and I would like to use the JAXP validation API. From Googling around, it appeared that I could use Jing and the ISO RELAX JARV to JAXP Bridge. Unfortunately, after adding both to my classpath, I can't get it to work. SchemaFactory is just throwing an IllegalArgumentException as soon as it tries to instantiate a factory — I looked inside SchemaFactory , apparently SchemaFactoryFinder is returning a null result. So I'd appreciate

cvc-complex-type.3.2.2: Attribute xsi:schemaLocation is not allowed to appear in <people> in Java DOM

不羁的心 提交于 2019-12-13 13:57:16
问题 I am attempting to validate my XML using XSD in Java by using DOM validator. Although, manually, I know that the document is indeed valid, DOM validator shouts back at me and says: cvc-complex-type.3.2.2: Attribute <xsi:schemaLocation> is not allowed to appear in the element <people> I have made sure that: setNamespaceAware() is set to true The schemaLanguage property was set before schemaSource schemaLanguage is set to http://ww.w3.org/2001/XMLSchema Both the XSD and XML are in the same

Is there any way to pass a DOM Object via an Intent and Parcelable?

我怕爱的太早我们不能终老 提交于 2019-12-13 02:36:50
问题 Is there any way to pass a JAXP Node or Document via an Intent and Parcelable? JAXP doesn't implement Parcelable, so the answer is probably --no. Is there any DOM library that implements Parcelable? Can someone provide a working example of that? Serialization isn't an option; nasty performance hit. Storing the data in res/xml is not an option: it must eventually (by end of project) be encrypted on disk. Android's "compiled" XML Access Tools do not support decrypting the whole XML. Of course I

JAXP - debug XSD catalog look up

℡╲_俬逩灬. 提交于 2019-12-13 02:25:30
问题 I have a situation where we want to validate an XML document held as a byte stream in memory, against an XSD placed amongst others in a file system. We would like to avoid having the file name explicitly mentioned in the XML file but instead tell the XML parser to use a catalog of one or more XSD files for validation. My attempt to create a DocumentBuilder provider (for Guice 3.0) looks like: public class ValidatingDocumentBuilderProvider implements Provider<DocumentBuilder> { static final

How can I provide custom error messages using JAXP DocumentBuilder?

好久不见. 提交于 2019-12-12 16:35:05
问题 I want to provide my own message from the validation done in DocumentBuilder , rather than the one from XMLMessages.properties . Now I see that a property error-reporter needs to be set to a class which extends XMLErrorReporter . However, I've not been able to get ComponentManager from Document / Builder / Factory . Doing parsing of string in SAXParseException is the last option, but I'm just thinking there may be a 'best practice' way of doing it. 回答1: have you already looked at

Are there any disadvantages to setNamespaceAware(true)?

不想你离开。 提交于 2019-12-12 12:49:35
问题 I was parsing an XML document, in Java, using the following code: DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Element el = db.parse(file).getDocumentElement(); However, when parsing an XML document that uses namespaces, I get the error: org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces. at org.apache.xerces.dom.ElementNSImpl