nodeList=doc.getElementsByTagName("update");//�õ����б�ǩΪupdate��node
buildeXmlObject(nodeList);
}
private static void buildeXmlObject(NodeList nodeList) {
for(int i=0;i<nodeList.getLength();i++){//��������sqlnode
SqlXmlObject sqlObject = new SqlXmlObject();//����һ������
Node node=nodeList.item(i);//�õ����е�һ��
NamedNodeMap nodeMap=node.getAttributes();
String sqlId=nodeMap.getNamedItem("id").getNodeValue();//�õ�id����
NodeList list=node.getChildNodes();//�õ�sql node���ӽڵ�
String sqlContent=list.item(0).getNodeValue();//�õ����е�sql
if(sqlContent==null||"".equals(sqlContent.trim())){
if(list.getLength()>0){
sqlContent=list.item(1).getNodeValue();
}
if(sqlContent==null||"".equals(sqlContent.trim())){
throw new RuntimeException("��sqlIdΪ"+sqlId+"��û���ҵ���Ч��sql���!");
}
}
String[] sqls=sqlContent.trim().split("\n");//�����н��зָ�
StringBuffer newSql=new StringBuffer();//����һ���µ��ַ������洢�ĺ��sql���
for(int j=0;j<sqls.length;j++){
newSql.append(fiterSql(sqls[j]));
}
sqlObject.setSqlId(sqlId);
sqlObject.setSqlContent(newSql.toString().trim());
//���ж��Ƿ��Ѿ�����,����о��׳��쳣
Object sqlObj=sqlMap.get(sqlId);
if(sqlObj!=null){
throw new RuntimeException("�Ѿ����ڱ��Ϊ"+sqlId+"��sql���!");
}