Is Scala/Java not respecting w3 “excess dtd traffic” specs?

后端 未结 9 1172
青春惊慌失措
青春惊慌失措 2021-02-01 07:40

I\'m new to Scala, so I may be off base on this, I want to know if the problem is my code. Given the Scala file httpparse, simplified to:

object Http {
   import         


        
9条回答
  •  生来不讨喜
    2021-02-01 08:32

    GClaramunt's solution worked wonders for me. My Scala conversion is as follows:

    package mypackage
    import org.xml.sax.{SAXNotRecognizedException, SAXNotSupportedException}
    import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
    import javax.xml.parsers.ParserConfigurationException
    
    @throws(classOf[SAXNotRecognizedException])
    @throws(classOf[SAXNotSupportedException])
    @throws(classOf[ParserConfigurationException])
    class MyXMLParserFactory extends SAXParserFactoryImpl() {
        super.setFeature("http://xml.org/sax/features/validation", false)
        super.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false)
        super.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false)
        super.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
    }
    

    As mentioned his the original post, it is necessary to place the following line in your code somewhere:

    System.setProperty("javax.xml.parsers.SAXParserFactory", "mypackage.MyXMLParserFactory")
    

提交回复
热议问题