2010-03-23 12 views
5

निम्न कोड में:java.io.IOException: सर्वर ने HTTP प्रतिक्रिया कोड: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd

private Document transformDoc(Source source) throws TransformerException, IOException { 
    TransformerFactory factory = TransformerFactory.newInstance(); 

    Transformer transformer = 
      factory.newTransformer(new StreamSource(xsltResource.getInputStream())); 
    JDOMResult result = new JDOMResult(); 
    transformer.transform(source, result); 
    return result.getDocument(); 
} 
URL के लिए 503

java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd 

एक्सएचटीएमएल मैं XSL के माध्यम से अधिक का अनुवाद कर रहा हूँ है:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> 
    <title>Terms and Conditions</title> 
</head> 
<body> 
    <div>Test Content</div> 
</body> 
</html> 

मैं कैसे Hom फोन से xalan ट्रांसफार्मर रोकूँ

मैं इस अपवाद ई?

उत्तर

1

This post from the Xalan-J mailing list सुझाव देता है कि अंतर्निहित Source/Reader स्वयं सत्यापन को अक्षम करने के लिए "सही तरीका" है।

+0

आप की जरूरत है इसे पाने के लिए 100% सही निम्नलिखित हैं, लेकिन वह मेलिंग सूची लिंक सबसे उपयोगी था! SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware (सत्य); spf.setValidating (झूठा); // सत्यापन बंद करें spf.setFeature ("http://apache.org/xml/features/nonvalidating/load-external-dtd", झूठा); XMLReader rdr = spf.newSAXParser()। GetXMLReader(); –

2

या तो पार्सर (पार्सर-विशिष्ट) में डीटीडी को हल करने या एक खाली इकाई रिज़ॉल्वर सेट करने को अक्षम करें।

http://www.jdom.org/docs/faq.html#a0350 से कॉपी किया गया:

public class NoOpEntityResolver implements EntityResolver { 
    public InputSource resolveEntity(String publicId, String systemId) { 
    return new InputSource(new StringBufferInputStream("")); 
    } 
} 

// Then in the builder... 

builder.setEntityResolver(new NoOpEntityResolver()); 
संबंधित मुद्दे