Commit 56176fbd by chengzhuoshen

修复xpath代码

parent 4c384059
......@@ -26,6 +26,7 @@ import javax.xml.datatype.XMLGregorianCalendar;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URL;
import java.util.*;
public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
......@@ -197,7 +198,9 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
try {
String[] paths = path.split("\\.");
SAXReader saxReader = new SAXReader();
Document document = saxReader.read(AbstractMx2MtCreator.class.getResource("/xsd/"+xsdName+".xsd"));
URL resource = AbstractMx2MtCreator.class.getResource("/xsd/" + xsdName + ".xsd");
if (resource == null) return false;
Document document = saxReader.read(resource);
Element element = document.getRootElement();
String minOccurs = null;
for (int i=0; i<paths.length; i++) {
......@@ -205,7 +208,10 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
if (p.indexOf("@") > -1) {
p = p.substring(0, p.indexOf("@"));
}
List<Node> nodeList = element.selectNodes("//xs:element[@name='"+p+"']");
if (p.indexOf("(") > -1) {
p = p.substring(0, p.indexOf("("));
}
List<Node> nodeList = element.selectNodes(".//xs:element[@name='"+p+"']");
if (nodeList == null || nodeList.size() == 0) {
continue;
}
......@@ -215,7 +221,9 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
} else {
String type = element.attributeValue("type");
nodeList = element.selectNodes("//xs:complexType[@name='"+type+"']");
element = (Element) nodeList.get(0);
if (nodeList != null && nodeList.size() > 0) {
element = (Element) nodeList.get(0);
}
}
}
if (minOccurs == null || Integer.parseInt(minOccurs) > 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment