SAX的异常处理。

SAXParseException 
SAXException
SAXParseException 主要用来处理,解析XML过程中出现的不可恢复的异常。比如一个xml中的某个元素不完整。SAXException
可能在startDocument(),endDocument(),startElement(),endElement(),characters()中抛出。
Handling NonFatal Errors
A nonfatal error occurs when an XML document fails a validity constraint. If the parser finds that the document is not valid, then an error event is generated. Such errors are generated by a validating parser, given a DTD or schema, when a document has an invalid tag, when a tag is found where it is not allowed, or (in the case of a schema) when the element contains invalid data.
 
值得注意的是它处理的a recoverable parser error.和前面的异常处理的机制是不同的。默认的DefaultHandler对这种错误是不做任何处理的,如果要额外处理,只要复写这个函数即可。
 public void error (SAXParseException e) throws SAXException

Handling Warnings
Warnings, too, are ignored by default. Warnings are informative can only be generated in the presence of a DTD or schema. For example, if an element is defined twice in a DTD, a warning is generated. It's not illegal, and it doesn't cause problems, but it's something you might like to know about because it might not have been intentional.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值