Thursday, 15 March 2012

scala xml EntityResolver equivilent -


I'm trying to parse Scala's XML to allow an entity to set up the resolver.

I 'is doing something wrong, but I am not getting enough documentation for the correct place for a DTD file, what is the correct way of pointing to the parser of scala?

  the object MyXML {def loadFile? (File: file) node = {println ( "loadFile called" val) parser: SAXParser = scala.xml.XML.parser parser.getParser.setEntityResolver (New MyXMLEntityResolver) // Try Also: parser.getXMLReader.setEntityResolver. .. Val inputSource = new InputSource (file.getAbsolutePath) Val loader = scala.xml.XML //scala.xml.XML.loadXML(inputSource .withSAXParser (parser) loader.loadFile (file) parser)} class MyXMLEntityResolver extends EntityResolver {override def resolveEntity (publicId: string, systemid: string): InputSource = {println (solution called "!") new input source (systemId)}}} / print called only "load file"  

The answer is that the important thing to override is that in the adapter method, the XMLLoader [T] is an adapter that instead of resolving, the installation of EntityResolver Parser with the code of code> Correct (even it does not work overriding!)

So, I have a class like this, which solve it is to think

  class MyXMLParser extends XMLLoader [Elem] {override def adapter = {new MyXMLAdapter}} class PhysicsXMLAdapter NoBindingFactoryAdapter {val myEntityResolver = new MyEn tityResolver extends (String, systemid: String publicId): InputSource = {myEntityResolver.resolveEntity (publicId, systemid)}}  
def resolveEntity override

No comments:

Post a Comment