プロジェクト自動化テストアーキテクチャの改良計画について-コンテンツファイルの動作指令情報について


次の3つの方法に分けて、解析を行います.
内部遍歴解析のコードは次のとおりです.
/**
* add the new information which configured in original xml and finally generate the new xml
*/
publicstaticString addElementToXML(String xmlString ,XMLModifyInfoExtractor extractor,String originalFilePath) throwsException{
Document doc = null;
doc = DocumentHelper.parseText(xmlString);
extractor.extractModifyInfo(originalFilePath);
//All the add information are provided by XMLModifyInfoExtractor
List  addElementInfoList = extractor.getAddElementInfoList();
List nodes ;
for(AddElement addElement : addElementInfoList){
String testcaseXPath =addElement.getTestcaseXPath();
String path =addElement.getPath();
String value=addElement.getValue();
//make the value as a Element block
Element newElementSnippet = DocumentHelper.parseText(value).getRootElement();          
nodes = doc.selectNodes(path);
for(Node node :nodes){
//if in the node is in matching testcase ,then remove it
String nodeUniquePath = node.getUniquePath();
if(nodeUniquePath.indexOf(testcaseXPath) !=-1){
//node.getParent().remove(node);
//node.setText(value);
Element addingPointElement = (Element) node;
addingPointElement.add(newElementSnippet);
}
}
}
returndoc.asXML();
}

内部要素を巡回するコードは次のとおりです.
/**
* update the information which configured in original xml and finally generate the new xml
*/
publicstaticString updateElementFromXML(String xmlString ,XMLModifyInfoExtractor extractor,String originalFilePath) throwsException{
Document doc = null;
doc = DocumentHelper.parseText(xmlString);
extractor.extractModifyInfo(originalFilePath);
//All the update information are provided by XMLModifyInfoExtractor
List  updateElementInfoList = extractor.getUpdateElementInfoList();
List nodes ;
for(UpdateElement updateElement : updateElementInfoList){
String testcaseXPath =updateElement.getTestcaseXPath();
String path =updateElement.getPath();
String value=updateElement.getValue();
nodes = doc.selectNodes(path);
for(Node node :nodes){
//if in the node is in matching testcase ,then remove it
String nodeUniquePath = node.getUniquePath();
if(nodeUniquePath.indexOf(testcaseXPath) !=-1){
node.setText(value);
}
}
}
returndoc.asXML();
}

中要素の遍歴解析を行うコードは次のとおりです.
/**
* remove the information which configured in original xml and finally generate the new xml
*/
publicstaticString removeElementFromXML(String xmlString ,XMLModifyInfoExtractor extractor,String originalFilePath) throwsException{
Document doc = null;
doc = DocumentHelper.parseText(xmlString);
extractor.extractModifyInfo(originalFilePath);
//All the remove information are provided by XMLModifyInfoExtractor
List  removeElementInfoList = extractor.getRemoveElementInfoList();
List nodes ;
for(RemoveElement removeElement : removeElementInfoList){
String testcaseXPath =removeElement.getTestcaseXPath();
String path =removeElement.getPath();
nodes = doc.selectNodes(path);
for(Node node :nodes){
//if in the node is in matching testcase ,then remove it
String nodeUniquePath = node.getUniquePath();
if(nodeUniquePath.indexOf(testcaseXPath) !=-1){
node.getParent().remove(node);
}
}
}
returndoc.asXML();
}

最後に、3ステップアクションシリーズ変換を実行すると、最終的なxmlファイルには最終的な修正結果が含まれます.