ibatis的cacheModel配置不满足"(flushInterval?,flushOnExecute*,property*)+"约束
给ibatis加cache时, 碰到一直报"The content of element type "cacheModel" must match "(flushInterval?,flushOnExecute*,property*)+". " 这个异常. 查了头天, 自己的格式完全符合, 最后把这些文件找出来单独验证. 我的XML:
card.xml
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "\bin\validateXML\sql-map.dtd"><sqlMap namespace="card"> <cacheModel id="product-cache" type="LRU"><flushInterval hours="24"/> <flushOnExecute statement="insertProduct"/><flushOnExecute statement="updateProduct"/><flushOnExecute statement="deleteProduct"/><property name="size" value="1000" /></cacheModel></sqlMap>
<!ELEMENT cacheModel (flushInterval?, flushOnExecute*, property*)+><!ATTLIST cacheModelid CDATA #REQUIREDtype CDATA #REQUIREDreadOnly (true | false) #IMPLIEDserialize (true | false) #IMPLIED>
import java.io.FileNotFoundException;import java.io.IOException;import javax.xml.parsers.DocumentBuilder;import javax.xml.parsers.DocumentBuilderFactory;import javax.xml.parsers.ParserConfigurationException;import org.xml.sax.SAXException;public class ValidateXMLDTD { public static void main(String[] args) { testXML(); } public static void testXML() { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true); DocumentBuilder db = dbf.newDocumentBuilder(); db.parse(ValidateXMLDTD.class.getResourceAsStream("card.xml")); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "\bin\validateXML\sql-map.dtd"><sqlMap namespace="card"> <cacheModel id="product-cache" type="LRU"><flushInterval hours="24"/><flushOnExecute statement="insertProduct"/><flushOnExecute statement="updateProduct"/><flushOnExecute statement="deleteProduct"/><property name="size" value="1000" /></cacheModel></sqlMap>