Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: dba03 <dba03@16...> - 2011-10-17 06:15:27
|
Finally, accrording to Michael's method, I impemented it. I just ignore the dtd validation. If mapping the dtd to local, just need to change the resolveEntity function and return a local dtd file. Thanks again. SAXParserFactory parserFactory = SAXParserFactory.newInstance(); SAXParser saxParser = parserFactory.newSAXParser(); XMLReader xmlReader = saxParser.getXMLReader(); EntityResolver entityReolver = new EntityResolver() { public InputSource resolveEntity(String publicId, String systemId) { try { System.out.println("Entity resolving systemID... " + publicId); if (systemId.indexOf((".dtd")) != -1) { System.out.println("Entity Resolved..."); return new InputSource(new ByteArrayInputStream("<?xml version='1.0' encoding='UTF-8'?>".getBytes())); } } catch (Exception e) { } return null; } }; xmlReader.setEntityResolver(entityReolver); SAXSource saxSource = new SAXSource(xmlReader, SAXSource.sourceToInputSource(new StreamSource(xmlFile))); transformer.transform(saxSource, result); 2011-10-17 dba03 发件人: dba03 发送时间: 2011-10-17 11:19:08 收件人: Mailing list for the SAXON XSLT and XQuery processor 抄送: 主题: Re: [saxon] java.net.SocketException: Unexpected end of filefromserver Thanks Michael Kay and Andrew Welch. Is there a way to simply disable dtd validation? I use the following code to call Saxon in java: System.setProperty("javax.xml.transform.TransformerFactory","net.sf.saxon.TransformerFactoryImpl"); TransformerFactory tfactory = TransformerFactory.newInstance(); System.out.println("load xslt file"); Templates templates = tfactory.newTemplates(new StreamSource(xsltFile)); Transformer transformer = templates.newTransformer(); Result result = new StreamResult(new File(filtTempXml)); transformer.transform(new StreamSource(xmlFile), result); 2011-10-17 dba03 发件人: Michael Kay 发送时间: 2011-10-14 17:42:16 收件人: saxon-help 抄送: 主题: Re: [saxon] java.net.SocketException: Unexpected end of file fromserver Your question breaks down into two parts: (a) how do you supply a (pre-configured) XML parser for Saxon to use (b) how do you configure an XML parser to use catalogs to resolve the DTD reference The answer on (a) is to use a SAXSource containing an XMLReader containing an EntityResolver. Alternatively you can supply a SourceParserClass to the Configuration, where the supplied class is your own implementation of XMLReader that wraps the real XML parser with your choice of configuration options. (b) is not really a Saxon question, and I don't have the answer at my fingertips, so I'll leave you to google it. Michael Kay Saxonica On 14/10/2011 09:42, dba03 wrote: > Hi Michael Kay, > > I use saxon(in java) to convert *.xhtml to *.xml. > There is > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > in the *.xhtml file. > > The result is: > java.net.SocketException: Unexpected end of file from server > > I have read the article: > http://www.scriptorium.com/2009/09/ignoring-doctype-in-xsl-transforms-using-saxon-9b/#hide > > But I call saxon in java program, and I have set URIResover for saxon because I use 'document()' function in XSL files. > > How to set a catalog file for saxon in Java program? thanks a lot. > > > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2d-oct > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > saxon-help@... > https://lists.sourceforge.net/lists/listinfo/saxon-help > ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@... https://lists.sourceforge.net/lists/listinfo/saxon-help |