SORU
30 EYLÜL 2008, Salı


DocumentBuilder Olun.ayrıştırma DTD başvuruları yoksayın

Xml dosyası (değişken f) bu yöntemi ben ayrıştırırken, bir hata alıyorum

C:\Documents ve Ayarlar\joe\Desktop\aicpcudev\OnlineModule\göster.dtd (sistem belirtilen yolu bulamıyor)

Dtd yok biliyorum, ne yapmam gerekir. Nasıl ayrıştırma bu DTD referans hatalarını görmezden gelerek Belge nesnesine nesne Dosyası miyim?

private static Document getDoc(File f, String docId) throws Exception{
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse(f);


    return doc;
}

CEVAP
1 EKİM 2008, ÇARŞAMBA


Bu DocumentBuilderFactory özellikleri ayarlamayı deneyin:

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

dbf.setValidating(false);
dbf.setNamespaceAware(true);
dbf.setFeature("http://xml.org/sax/features/namespaces", false);
dbf.setFeature("http://xml.org/sax/features/validation", false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

DocumentBuilder db = dbf.newDocumentBuilder();
...

Sonuçta, seçenekleri parser uygulaması için özel olduğunu düşünüyorum. Eğer yardımı olacaksa, Here is some documentation for Xerces2.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • cdgotx

    cdgotx

    8 Kasım 2011
  • Monica Catral

    Monica Catra

    12 NİSAN 2009
  • tychoadragmire

    tychoadragmi

    20 Mart 2006