ngallagher / simplexml

Simple XML
Apache License 2.0
97 stars 38 forks source link

Maximum attribute size limit (524288) exceeded #36

Open mrlimbic opened 6 years ago

mrlimbic commented 6 years ago

I have an XML with exceptionally long values in it.

This appears to be due simplexml using woodstox but it is not reading the properties that can change these max allowable values. How can I change max attribute size to >512K?

javax.xml.stream.XMLStreamException: Maximum attribute size limit (524288) exceeded at com.ctc.wstx.sr.StreamScanner.constructLimitViolation(StreamScanner.java:2470) at com.ctc.wstx.sr.StreamScanner.verifyLimit(StreamScanner.java:2463) at com.ctc.wstx.sr.BasicStreamReader.parseAttrValue(BasicStreamReader.java:2041) at com.ctc.wstx.sr.BasicStreamReader.handleNsAttrs(BasicStreamReader.java:3145) at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:3043) at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2919) at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1123) at org.codehaus.stax2.ri.Stax2EventReaderImpl.nextEvent(Stax2EventReaderImpl.java:255) at org.simpleframework.xml.stream.StreamReader.read(StreamReader.java:110) at org.simpleframework.xml.stream.StreamReader.next(StreamReader.java:94) at org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java:121) at org.simpleframework.xml.stream.NodeReader.skipElement(NodeReader.java:337) at org.simpleframework.xml.stream.InputElement.skip(InputElement.java:245) at org.simpleframework.xml.core.Composite.readElement(Composite.java:529) at org.simpleframework.xml.core.Composite.readElements(Composite.java:445) at org.simpleframework.xml.core.Composite.access$400(Composite.java:59) at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383) at org.simpleframework.xml.core.Composite.read(Composite.java:201) at org.simpleframework.xml.core.Composite.read(Composite.java:148) at org.simpleframework.xml.core.Traverser.read(Traverser.java:92) at org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:190) at org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:167) at org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:144) at org.simpleframework.xml.core.CompositeListUnion.readElement(CompositeListUnion.java:189) at org.simpleframework.xml.core.CompositeListUnion.read(CompositeListUnion.java:162) at org.simpleframework.xml.core.Variable$Adapter.read(Variable.java:482) at org.simpleframework.xml.core.Composite.readVariable(Composite.java:613) at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573) at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549) at org.simpleframework.xml.core.Composite.readElement(Composite.java:532) at org.simpleframework.xml.core.Composite.readElements(Composite.java:445) at org.simpleframework.xml.core.Composite.access$400(Composite.java:59) at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383) at org.simpleframework.xml.core.Composite.read(Composite.java:201) at org.simpleframework.xml.core.Composite.read(Composite.java:148) at org.simpleframework.xml.core.Traverser.read(Traverser.java:92) at org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:190) at org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:167) at org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:124) at org.simpleframework.xml.core.CompositeListUnion.readElement(CompositeListUnion.java:129) at org.simpleframework.xml.core.CompositeListUnion.read(CompositeListUnion.java:107) at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623) at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573) at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549) at org.simpleframework.xml.core.Composite.readElement(Composite.java:532) at org.simpleframework.xml.core.Composite.readElements(Composite.java:445) at org.simpleframework.xml.core.Composite.access$400(Composite.java:59) at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383) at org.simpleframework.xml.core.Composite.read(Composite.java:201) at org.simpleframework.xml.core.Composite.read(Composite.java:148) at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623) at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573) at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549) at org.simpleframework.xml.core.Composite.readElement(Composite.java:532) at org.simpleframework.xml.core.Composite.readElements(Composite.java:445) at org.simpleframework.xml.core.Composite.access$400(Composite.java:59) at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383) at org.simpleframework.xml.core.Composite.read(Composite.java:201) at org.simpleframework.xml.core.Composite.read(Composite.java:148) at org.simpleframework.xml.core.Traverser.read(Traverser.java:92) at org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:190) at org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:167) at org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:124) at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623) at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573) at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549) at org.simpleframework.xml.core.Composite.readElement(Composite.java:532) at org.simpleframework.xml.core.Composite.readElements(Composite.java:445) at org.simpleframework.xml.core.Composite.access$400(Composite.java:59) at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383) at org.simpleframework.xml.core.Composite.read(Composite.java:201) at org.simpleframework.xml.core.Composite.read(Composite.java:148) at org.simpleframework.xml.core.Traverser.read(Traverser.java:92) at org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:190) at org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:167) at org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:124) at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623) at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573) at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549) at org.simpleframework.xml.core.Composite.readElement(Composite.java:532) at org.simpleframework.xml.core.Composite.readElements(Composite.java:445) at org.simpleframework.xml.core.Composite.access$400(Composite.java:59) at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383) at org.simpleframework.xml.core.Composite.read(Composite.java:201) at org.simpleframework.xml.core.Composite.read(Composite.java:148) at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623) at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573) at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549) at org.simpleframework.xml.core.Composite.readElement(Composite.java:532) at org.simpleframework.xml.core.Composite.readElements(Composite.java:445) at org.simpleframework.xml.core.Composite.access$400(Composite.java:59) at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383) at org.simpleframework.xml.core.Composite.read(Composite.java:201) at org.simpleframework.xml.core.Composite.read(Composite.java:148) at org.simpleframework.xml.core.Traverser.read(Traverser.java:92) at org.simpleframework.xml.core.Persister.read(Persister.java:625) at org.simpleframework.xml.core.Persister.read(Persister.java:606) at org.simpleframework.xml.core.Persister.read(Persister.java:584) at org.simpleframework.xml.core.Persister.read(Persister.java:543) at org.simpleframework.xml.core.Persister.read(Persister.java:521) at net.vordio.ui.ConvertController$FCPXConverterTask.call(ConvertController.java:1173) at javafx.concurrent.Task$TaskCallable.call(Task.java:1423) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.lang.Thread.run(Thread.java:748)

mrlimbic commented 6 years ago

Apparently the correct way is to set a woodstox system property. But it doesn't work via simplexml.

com.ctc.wstx.maxAttributeSize=

mrlimbic commented 6 years ago

I've tried using the recommended system property but it doesn't seem to pick it up.

-Djavax.xml.stream.XMLInputFactory=com.ctc.wstx.stax.WstxInputFactory -Dcom.ctc.wstx.maxAttributeSize=10000000

ngallagher commented 5 years ago

Is there is no reason you can't use another StAX provider, or DOM or XmlPull?

mrlimbic commented 5 years ago

I don't know why wstx is not picking up System properties from command line but I found a way to configure it in code instead.

// Force use of our custom XML input factory (patch for FCPX LUT problem)
System.getProperties().put("javax.xml.stream.XMLInputFactory", InputFactory.class.getName());           

// Hack to fix FCPX XML LUT problems with massive attribute data
public static class InputFactory extends WstxInputFactory {
    public InputFactory() {
        super();
        setProperty(WstxInputProperties.P_MAX_ATTRIBUTE_SIZE, Integer.MAX_VALUE);
    }
}