Tag: xerces

XMLSchema的解决方法不支持maxOccurs大于5000

我的问题是解析一个XSD Schema,它包含maxOccurs大于5000(但不是unbounded )的元素。 这实际上是Xerces(我正在使用的版本2.9.1)或JAXP中的一个已知问题,如下所述: http ://bugs.sun.com/view_bug.do;jsessionid=85335466c2c1fc52f0245d20b2e?bug_id= 4990915 我已经知道,如果我将XSD中的maxOccurs数字从大于5000的数字更改为unbounded一切正常。 遗憾的是,在我的情况下这不是一个选项 (我不能插入XSD文件)。 我的问题是: 有人知道Xerces中有关此问题的其他一些解决方法吗? 要么 有人可以推荐另一个没有此限制的XML解析器吗? 谢谢!

Struts2和Tiles:当apache.org关闭时,我的webapp无法启动

我正在构建一个使用磁贴的Struts2 Web应用程序但是我发现了一个非常令人沮丧的问题,即如果apache.org关闭(这似乎经常发生)Web应用程序无法启动。 这是因为在其标准设置中,StrutsTilesListener尝试加载tiles defenitions文件,该文件包含一个带有public-id的DOCTYPE,该公共id指向位于tiles.apache.org上的DTD。 当应用程序启动时,定义文件使用Apache Xerces通过Apache Commons Digester加载,它尝试从tiles.apache.org加载DTD但是如果apache.org关闭则会失败,并且随之而来的是整个Web应用程序无法启动。 我可以通过下载文件并将其置于本地并在struts定义文件中指定新的本地位置来绕过远程位置的下载,但是这个解决方案不是非常便携,因为DTD在本地保存的位置可能会有所不同开发人员机器和不同的一旦上传到实时环境,所以我将不得不继续编辑位置,以便运行webapp运行的机器,这简直是烦人的。 项目中没有其他xml文件存在此问题,包括struts.xml文件,该文件在apache.org上也有一个DTD位置,因此很明显存在一个设置问题,其中Tiles严格要求DTD但其他组件不是。 这有什么解决方案吗? 我已经没有耐心了,我不能把这个网络应用程序告知,如果apache.org在重新启动时关闭,webapp将不会恢复。 Struts tile defenition文件 当apache.org关闭时,堆栈跟踪 SEVERE: Exception sending context initialized event to listener instance of class org.apache.struts2.tiles.StrutsTilesListener java.lang.IllegalStateException: Unable to instantiate container. at org.apache.tiles.web.startup.TilesListener.contextInitialized(TilesListener.java:60) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:581) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native […]

加载我自己的Xalan实现,其中旧的Xalan被加载到父类加载器

我正在为一个框架编写一个插件,它将我的代码加载为子类加载器 问题是该框架使用某个Xerces版本,与我的代码不兼容,我想使用我自己的“jar”用于xerces,但似乎既然旧的已经加载了,我似乎无法制作我的代码使用我的。 我正在寻找一些类加载器分离,我知道这是一个已知的问题,但似乎无法解决它 在这种情况下,是否有任何框架,库或代码示例在本地用户使用较新的jar?

的SAXParseException; src-resolve:无法将名称“…”解析为(n)’类型定义’组件

我正在尝试进行模式validation,目前使用的是javax.xml.validation.SchemaFactory 。 不幸的是,当我调用newSchema(Source schema)函数时,我收到以下错误: Caused by: org.xml.sax.SAXParseException; systemId: file:/C:/Users/C42056/Documents/workspace-sts-3.2.0.RELEASE/cec-sample-ws-integration-2-war/target/classes/WEB-INF/schemas/xsd/individual/PrivateComponentTypes_4_0.xsd; lineNumber: 33; columnNumber: 88; src-resolve: Cannot resolve the name ‘utility:ObjectStatusDateType’ to a(n) ‘type definition’ component. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaError(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaError(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.getGlobalDecl(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseNamedElement(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseLocal(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.traverseLocalElements(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source) at […]

Xerces DOM解析器非常慢?

目前,我正在尝试使用JTidy清理HTML文件,将其转换为XHTML并将结果提供给DOM解析器。 以下代码是这些努力的结果: public class HeaderBasedNewsProvider implements INewsProvider { /* … */ public Collection getNewsEntries() throws NewsUnavailableException { Document document; try { document = getCleanedDocument(); } catch (Exception e) { throw new NewsUnavailableException(e); } System.err.println(document.getDocumentElement().getTextContent()); return null; } private final Document getCleanedDocument() throws IOException, SAXException, ParserConfigurationException { InputStream input = inputStreamProvider.getInputStream(); Tidy tidy = new Tidy(); […]

XIncludeAwareParserConfiguration与XMLParserConfiguration不兼容

在AIX平台上将ear文件部署到WLS 10.3时,我收到此错误。 同样的耳朵在Windows / Linux平台上运行良好。 Caused by: java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration incompatible with org.apache.xerces.xni.parser.XMLParserConfiguration at org.apache.xerces.parsers.DOMParser.(Unknown Source) at org.apache.xerces.parsers.DOMParser.(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderImpl.(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source) at weblogic.xml.jaxp.WebLogicDocumentBuilderFactory.newDocumentBuilder(WebLogicDocumentBuilderFactory.java:140) at com.bea.security.xacml.policy.PolicyUtils.getRootNode(PolicyUtils.java:54) at com.bea.security.xacml.policy.PolicyUtils.read(PolicyUtils.java:86) at com.bea.security.providers.xacml.store.BasePolicyStore.getAbstractPolicy(BasePolicyStore.java:1251) at com.bea.security.providers.xacml.store.BasePolicyStore.readPolicy(BasePolicyStore.java:1231) at com.bea.security.providers.xacml.store.BasePolicyStore.readPolicy(BasePolicyStore.java:1114) at com.bea.security.providers.xacml.entitlement.PolicyManager.listPolicies(PolicyManager.java:747) at weblogic.security.providers.xacml.DeployableAuthorizationProviderV2Helper.startDeployPolicies(DeployableAuthorizationProviderV2Helper.java:90) at weblogic.security.providers.xacml.authorization.XACMLAuthorizationProviderImpl.startDeployPolicies(XACMLAuthorizationProviderImpl.java:269) at com.bea.common.security.internal.legacy.service.PolicyDeployerProviderImpl$V2Adapter.startDeployPolicies(PolicyDeployerProviderImpl.java:69) at com.bea.common.security.internal.service.PolicyDeploymentServiceImpl$DeploymentHandlerImpl.(PolicyDeploymentServiceImpl.java:143) at com.bea.common.security.internal.service.PolicyDeploymentServiceImpl$DeploymentHandlerImpl.(PolicyDeploymentServiceImpl.java:129) at com.bea.common.security.internal.service.PolicyDeploymentServiceImpl$ServiceImpl.startDeployPolicies(PolicyDeploymentServiceImpl.java:97) at weblogic.security.service.WLSPolicyDeploymentServiceWrapper$DeploymentHandlerImpl.(WLSPolicyDeploymentServiceWrapper.java:70) at weblogic.security.service.WLSPolicyDeploymentServiceWrapper$DeploymentHandlerImpl.(WLSPolicyDeploymentServiceWrapper.java:60) at […]

ClassCastException:org.apache.xerces.parsers.XIncludeAwareParserConfiguration无法强制转换为org.apache.xerces.xni.parser.XMLParserConfiguration

我正在Eclipse中开发一个GWT应用程序并使用jdom2来读取一些自定义的xml属性文件。 在最近的更新之后,我的应用程序现在在尝试读取xml文件时失败并出现上述错误。 相关的堆栈跟踪是: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration org.apache.xerces.parsers.SAXParser.(Unknown Source) org.apache.xerces.parsers.SAXParser.(Unknown Source) org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.(Unknown Source) org.apache.xerces.jaxp.SAXParserImpl.(Unknown Source) org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown Source) org.jdom2.input.sax.XMLReaders.createXMLReader(XMLReaders.java:165) org.jdom2.input.SAXBuilder.createParser(SAXBuilder.java:871) org.jdom2.input.SAXBuilder.buildEngine(SAXBuilder.java:854) org.jdom2.input.SAXBuilder.getEngine(SAXBuilder.java:904) org.jdom2.input.SAXBuilder.build(SAXBuilder.java:1116) uk.co.platosys.db.jdbc.DatabaseProperties.loadProperties(DatabaseProperties.java:78) 研究此问题表明,当类路径上存在不兼容的xerces jar版本时,可能会出现错误。 gwt-dev-2.6.1.jar包含xerces包,我的预感是这个最新版本的gwt-dev捆绑了一个不兼容的版本。 然而,当前版本的jdom2.0.5与2.11版本的Xerces一起发布,这似乎是Apache最新发布的版本。 将这些jar放在我的类路径上似乎并不能解决问题; 我以前能够依赖gwt-dev中的版本。 我宁愿在这方面做到这一点,而且远远超出了我的舒适区。

XercesImpl与JavaSE 6的内部xerces实现相冲突。 两者都需要……可以做些什么?

我确信我不是第一个遇到这种冲突的人。 我inheritance的代码执行以下操作: org.w3c.dom.Document dom; // declaration javax.xml.validation.Schema schema; // declaration … … … javax.xml.validation.Validator validator = schema.newValidator(); validator.validate(new DOMSource(dom)); …代表看似不重要/不相关的代码 使用JDK 6编译和运行代码可以工作(并且总是有……) 最近我不得不将我公司其他地方编写的另一个组件集成到我的代码中。 该组件绝对需要包含在xercesImpl-2.8.1.jar的类路径中 我绝对需要这个第三方组件, 但现在运行上面的代码不再有效,我得到以下内容: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘Root’. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown […]

如何防止具有META-INF \ services \ javax.xml.transform.TransformerFactory的xalan.jar接管内置在Xalan实现中的JDK 1.6?

考虑一下这段代码(完全基于飞碟的“入门”代码,保留其权利): package flyingsaucerpdf; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; import org.xhtmlrenderer.pdf.ITextRenderer; public class PDFMaker { public static void main(String[] args) throws Exception { new PDFMaker().go(); } public void go() throws Exception { String inputFile = “sample.html”; String url = new File(inputFile).toURI().toURL().toString(); String outputFile = “firstdoc.pdf”; OutputStream os = new FileOutputStream(outputFile); ITextRenderer renderer = new ITextRenderer(); […]

治愈“字符串” – “评论中不允许”。 例外?

我正在使用Java 6.我在我的pom中有这种依赖… xerces xercesImpl 2.10.0 我正在尝试使用此行解析XHTML文档 使用此代码…… DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); factory.setExpandEntityReferences(false); factory.setFeature(“http://apache.org/xml/features/nonvalidating/load-external-dtd”, false); final DocumentBuilder builder = factory.newDocumentBuilder(); final InputSource s = new InputSource(new StringReader(str)); org.w3c.dom.Document result = builder.parse(s); 但我的解析因以下exception而死亡…… [Fatal Error] :91:947: The string “–” is not permitted within comments. org.xml.sax.SAXParseException: The string “–” is not permitted within comments. at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) […]