之前我使用过DOM解析器,将DTD文件放在项目下,DOM代码可以检测DTD文件本身并根据规则解析文件。
当我转移到SAX解析器时,似乎SAX解析器无法在没有设置的情况下检测到DTD文件本身。有些帖子被提及使用// unlock CRTC registers
outb_p(0x3, 0x3d4);
outb_p(inb_p(0x3d5) | 0x80, 0x3d5);
outb_p(0x11, 0x3d4);
outb_p(inb_p(0x3d5) & ~0x80, 0x3d5);
outb_p(0x10, 0x3c0); outb_p(0x01, 0x3c1); // mode control
outb_p(0x11, 0x3c0); outb_p(0x00, 0x3c1); // overscan register
outb_p(0x12, 0x3c0); outb_p(0x0f, 0x3c1); // color plane enable
outb_p(0x13, 0x3c0); outb_p(0x00, 0x3c1); // horizontal plane enable
outb_p(0x14, 0x3c0); outb_p(0x00, 0x3c1); // color select
outb_p(0xe3, 0x3c2); // misc out register
outb_p(0x01, 0x3c4); outb_p(0x01, 0x3c5); // clock mode register
outb_p(0x03, 0x3c4); outb_p(0x00, 0x3c5); // character select
outb_p(0x04, 0x3c4); outb_p(0x02, 0x3c5); // memory mode register
outb_p(0x05, 0x3ce); outb_p(0x00, 0x3cf); // mode register
outb_p(0x06, 0x3ce); outb_p(0x05, 0x3cf); // misc register
outb_p(0x00, 0x3d4); outb_p(0x5f, 0x3d5); // horizontal total
outb_p(0x01, 0x3d4); outb_p(0x4f, 0x3d5); // horizontal display enable end
outb_p(0x02, 0x3d4); outb_p(0x50, 0x3d5); // horizontal blank start
outb_p(0x03, 0x3d4); outb_p(0x82, 0x3d5); // horizontal blank end
outb_p(0x04, 0x3d4); outb_p(0x54, 0x3d5); // horizontal retrace start
outb_p(0x05, 0x3d4); outb_p(0x80, 0x3d5); // horizontal retrace end
outb_p(0x06, 0x3d4); outb_p(0x0b, 0x3d5); // vertical total
outb_p(0x07, 0x3d4); outb_p(0x3e, 0x3d5); // overflow register
outb_p(0x08, 0x3d4); outb_p(0x00, 0x3d5); // preset row scan
outb_p(0x09, 0x3d4); outb_p(0x40, 0x3d5); // max scan line
outb_p(0x10, 0x3d4); outb_p(0xea, 0x3d5); // vertical retrace start
outb_p(0x11, 0x3d4); outb_p(0x8c, 0x3d5); // vertical retrace end
outb_p(0x12, 0x3d4); outb_p(0xdf, 0x3d5); // vertical display enable end
outb_p(0x13, 0x3d4); outb_p(0x28, 0x3d5); // logical width
outb_p(0x14, 0x3d4); outb_p(0x00, 0x3d5); // underline location
outb_p(0x15, 0x3d4); outb_p(0xe7, 0x3d5); // vertical blank start
outb_p(0x16, 0x3d4); outb_p(0x04, 0x3d5); // vertical blank end
outb_p(0x17, 0x3d4); outb_p(0xe3, 0x3d5); // mode control
,但我无法理解。任何人都可以帮我解决这个问题,以一种简单的方式将本地DTD文件加载到我的java代码中(在没有CMD的eclipse中)?
如果有人能提供代码示例,那就是最好的。
答案 0 :(得分:0)
我发布了一个有效的解决方案,我从SAX文档中获取了输入。我使用了来自W3 Schools的样本DTD和XML(http://www.w3schools.com/xml/xml_dtd.asp),如果它在一个单独的文件上,则不需要DOCTYPE,因此从DTD中删除了一行。不确定它是否是你想要的样品,希望它有所帮助!
public static void main(String[] args) {
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
XMLReader reader = factory.newSAXParser().getXMLReader();
reader.parse(new InputSource(new FileInputStream("C:\\DevelopmentTools\\3.CODE\\SAX-XML.txt")));
reader.setEntityResolver(new EntityResolver() {
@Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
// TODO Auto-generated method stub
if (systemId == null) {
systemId = "C:\\DevelopmentTools\\3.CODE\\99.WORKSPACE\\Note.dtd";
}
InputSource result = null;
result = new InputSource(systemId);
return result;
}
});
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}