xerces

Xerces-C validate xml with hardcoded xsd

半腔热情 提交于 2019-11-28 13:03:40
I'm writing a library which takes xml files and parses them. To prevent users from feeding inalid xmls into my application i'm using xerces to validate the xml files via an xsd. However, i only manages to validate against xsd-files. Theoretically an user could just open this file and mess around with it. That's why i would like my xsd to be hardcoded in my library. Unfortunately i haven't found a way to do this with XercesC++, yet. That's how it is working right now... bool XmlParser::validateXml(std::string a_XsdFilename) { xercesc::XercesDOMParser domParser; if (domParser.loadGrammar(a

Validating document in Xerces C++

谁说我不能喝 提交于 2019-11-28 12:21:41
问题 I want to load an XML document in Xerces-C++ (version 2.8, under Linux), and validate it using a DTD schema not referenced from the document. I tried the following: XercesDOMParser parser; parser.loadGrammar("grammar.dtd", Grammar::DTDGrammarType); parser.setValidationScheme(XercesDOMParser::Val_Always); parser.parse("xmlfile.xml"); But it doesn't indicate an error if the document is not valid. What am I missing? 回答1: You'll need to set an error handler before calling parse if you want to see

Cure for 'The string “--” is not permitted within comments.' exception?

本小妞迷上赌 提交于 2019-11-28 09:00:59
I'm using Java 6. I have this dependency in my pom ... <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.10.0</version> </dependency> I'm trying to parse an XHTML doc with this line <!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>EN-US</w

after update Apache POI 4.0 - Property 'http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit' is not recognized

好久不见. 提交于 2019-11-28 06:27:52
问题 After updating Apache POI from 3.17 to 4.0.0 i'm getting on line: OPCPackage pck = OPCPackage.open(this.getTemplate()); an exception: java.lang.IllegalArgumentException: Property 'http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit' is not recognized. at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(DocumentBuilderFactoryImpl.java:144) at __redirected.__DocumentBuilderFactory.setAttribute(__DocumentBuilderFactory.java:125) at org.apache.poi.ooxml.util

Is it an error to import the same XSD multiple times?

梦想与她 提交于 2019-11-28 02:22:26
I have a schema (a) that imports another schema (z). Then I have yet another schema (b) that imports that same schema (z). It happens so that XML document (d) conforming to schema (a) can also contain an optional element that conforms to schema (z). In consequence, when (d) is validated in .NET, I'm having exception "The simpleType 'z:x' has already been declared." But there is no exception in Oxygen. I'd like to configure .net the way it does NOT throw this exception. Just to behave like Oxygen. How? The problem arises due to the XSD Recommendation allowing, but not requiring, conformant

why org.apache.xerces.parsers.SAXParser does not skip BOM in utf8 encoded xml?

和自甴很熟 提交于 2019-11-28 01:57:52
I have an xml with utf8 encoding. And this file contains BOM a beginning of the file. So during parsing I am facing with org.xml.sax.SAXParseException: Content is not allowed in prolog. I can not remove those 3 bytes from the files. I can not load file into memory and remove them here (files are big). So for performance reasons I'm using SAX parser and want just to skip those 3 bytes if they are present before "" tag. Should I inherit InputStreamReader for this? I'm new in java - show me the right way please. Adrian Cox This has come up before, and I found the answer on Stack Overflow when it

How can I parse XML that confirms to the 1.1 spec using Java and Xerces?

£可爱£侵袭症+ 提交于 2019-11-28 01:33:19
问题 I'm trying to parse a String which contains XML content which conforms to the XML 1.1 spec. The XML contains character references which are not allowed in the XML 1.0 spec but which are allowed in the XML 1.1 spec (character references which translate to Unicode characters in the range U+0001–U+001F). According the Xerces2 website, the Xerces2 parser supports parsing XML 1.1 documents. However, I cannot figure out how to tell it the XML we are trying to parse contains 1.1-compliant XML. I'm

Change the com.sun.org.apache.xml.internal.serialize.XMLSerializer & com.sun.org.apache.xml.internal.serialize.OutputFormat

拜拜、爱过 提交于 2019-11-27 16:08:58
Using com.sun.org.apache.xml.internal.serialize.XMLSerializer and com.sun.org.apache.xml.internal.serialize.OutputFormat causes some errors when compiling using java 1.6. The solution I found is by using org.apache.xml.serialize.XMLSerializer and org.apache.xml.serialize.OutputFormat after adding xerces. The problem is that theses classes are deprecated. What can I use without to replace them without touching the code ? Thnx This is the dependency I used : <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.9.1</version> </dependency> We can use the

Xerces error: org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl

百般思念 提交于 2019-11-27 12:05:48
I'm developing a web application using JSF 2.0, NetBeans 6.9.1, GlassFish Server 3.1, mojarra 2.0.3, and JasperReports 3.7.6. Included in my project library is the jar file "xerces-2.8.0.jar". This file was imported as part of the JasperReports jar file library. Whenever I try to deploy, run, or debug my project through NetBeans, I receive this error: java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! DTD factory class org.apache.xerces.impl.dv.dtd

Validate an XML File Against Multiple Schema Definitions

青春壹個敷衍的年華 提交于 2019-11-27 07:47:40
I'm trying to validate an XML file against a number of different schemas (apologies for the contrived example): a.xsd b.xsd c.xsd c.xsd in particular imports b.xsd and b.xsd imports a.xsd, using: <xs:include schemaLocation="b.xsd"/> I'm trying to do this via Xerces in the following manner: XMLSchemaFactory xmlSchemaFactory = new XMLSchemaFactory(); Schema schema = xmlSchemaFactory.newSchema(new StreamSource[] { new StreamSource(this.getClass().getResourceAsStream("a.xsd"), "a.xsd"), new StreamSource(this.getClass().getResourceAsStream("b.xsd"), "b.xsd"), new StreamSource(this.getClass()