Skip to content

Commit

Permalink
more code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanetteclark committed Mar 4, 2024
1 parent 537af5a commit f8a55ac
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/java/edu/ucsb/nceas/mdqengine/processor/XMLDialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ private void extractNamespaces() {
XPath xpath = xPathfactory.newXPath();
NodeList nodes = null;
try {
// String selectorPath = "//*[namespace-uri()]/concat(substring-before(name(),
// ':'),':',namespace-uri())";
String selectorPath = "//*[namespace-uri()]";

nodes = (NodeList) xpath.evaluate(selectorPath, this.nsAwareDocument, XPathConstants.NODESET);
Expand Down Expand Up @@ -384,8 +382,9 @@ private Object selectPath(Selector selector, Node contextNode) throws XPathExpre
String uri = entry.getUri();
// Some metadata files may have improper xmlns declarations that don't include
// a prefix (encountered in Dryad Data), so skip these.
if (prefix == null)
if (prefix == null){
continue;
}

// make sure we are overriding the found namespace[s] with the asserted ones
String existing = nsContext.getNamespaceURI(prefix);
Expand Down Expand Up @@ -461,8 +460,7 @@ else if (nodes.getLength() > 0 || selector.getSubSelector() != null) {
public static Object retypeObject(Object value) {
Object result = value;

if (value instanceof String) {
String stringValue = (String) value;
if (value instanceof String stringValue) {
// try to type the value correctly
if (NumberUtils.isNumber(stringValue) && !stringValue.matches("^0\\d*$")) {
// If it's a valid number and doesn't start with zeros, create a Number object
Expand Down Expand Up @@ -509,7 +507,7 @@ private String toXmlString(Document document) {
transformer.transform(source, result);
return result.getWriter().toString();
} catch (TransformerException ex) {
ex.printStackTrace();
log.error("Error transforming to XML string." + ex.getMessage());
return null;
}

Expand Down

0 comments on commit f8a55ac

Please sign in to comment.