diff --git a/impexp-client-gui/build.gradle b/impexp-client-gui/build.gradle index 9e188758c..6488b2cae 100644 --- a/impexp-client-gui/build.gradle +++ b/impexp-client-gui/build.gradle @@ -11,9 +11,9 @@ configurations { dependencies { api project(':impexp-client-cli') - api 'com.formdev:flatlaf:1.6' - api 'com.formdev:flatlaf-extras:1.6' - api 'com.formdev:flatlaf-swingx:1.6' + api 'com.formdev:flatlaf:1.6.1' + api 'com.formdev:flatlaf-extras:1.6.1' + api 'com.formdev:flatlaf-swingx:1.6.1' api 'com.fifesoft:rsyntaxtextarea:3.1.3' api ('org.citydb:swingx-ws:1.1.5') { transitive = false diff --git a/impexp-core/src/main/java/org/citydb/core/database/schema/util/SimpleXPathParser.java b/impexp-core/src/main/java/org/citydb/core/database/schema/util/SimpleXPathParser.java index 30a09813c..6952c831e 100644 --- a/impexp-core/src/main/java/org/citydb/core/database/schema/util/SimpleXPathParser.java +++ b/impexp-core/src/main/java/org/citydb/core/database/schema/util/SimpleXPathParser.java @@ -27,18 +27,7 @@ */ package org.citydb.core.database.schema.util; -import org.citydb.core.database.schema.mapping.AbstractAttribute; -import org.citydb.core.database.schema.mapping.AbstractPathElement; -import org.citydb.core.database.schema.mapping.AbstractProperty; -import org.citydb.core.database.schema.mapping.AbstractType; -import org.citydb.core.database.schema.mapping.AbstractTypeProperty; -import org.citydb.core.database.schema.mapping.ComplexAttribute; -import org.citydb.core.database.schema.mapping.ComplexAttributeType; -import org.citydb.core.database.schema.mapping.FeatureType; -import org.citydb.core.database.schema.mapping.PathElementType; -import org.citydb.core.database.schema.mapping.SchemaMapping; -import org.citydb.core.database.schema.mapping.SimpleAttribute; -import org.citydb.core.database.schema.mapping.SimpleType; +import org.citydb.core.database.schema.mapping.*; import org.citydb.core.database.schema.path.AbstractNodePredicate; import org.citydb.core.database.schema.path.FeatureTypeNode; import org.citydb.core.database.schema.path.InvalidSchemaPathException; @@ -46,14 +35,7 @@ import org.citydb.core.database.schema.path.predicate.comparison.EqualToPredicate; import org.citydb.core.database.schema.path.predicate.logical.BinaryLogicalPredicate; import org.citydb.core.database.schema.path.predicate.logical.LogicalPredicateName; -import org.citydb.core.query.filter.selection.expression.AbstractLiteral; -import org.citydb.core.query.filter.selection.expression.BooleanLiteral; -import org.citydb.core.query.filter.selection.expression.DateLiteral; -import org.citydb.core.query.filter.selection.expression.DoubleLiteral; -import org.citydb.core.query.filter.selection.expression.LiteralType; -import org.citydb.core.query.filter.selection.expression.LongLiteral; -import org.citydb.core.query.filter.selection.expression.StringLiteral; -import org.citydb.core.query.filter.selection.expression.TimestampLiteral; +import org.citydb.core.query.filter.selection.expression.*; import org.citydb.core.registry.ObjectRegistry; import javax.xml.XMLConstants; @@ -62,14 +44,16 @@ import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.NamespaceContext; import javax.xml.namespace.QName; +import java.util.ArrayList; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public class SimpleXPathParser { // this parser only supports XPath subset as defined in OGC 09-026r2, Annex D - private final String simplifiedStepExpr_ = "([^\\[]+)(?:\\[(.+)\\]$)?"; + private final String simplifiedStepExpr_ = "([^\\[]+)(?:\\[(.+)]$)?"; private final String nameChar_ = "[_a-zA-Z][\\w\\-.]*"; - private final String stringLiteral_ = "\"(?:(?:\"\")|[^\"])*?\"|'(?:(?:'')|[^\"])*?'"; + private final String stringLiteral_ = "\"(?:\"\"|[^\"])*?\"|'(?:''|[^'])*?'"; private final String qName_ = "(?:(" + nameChar_ + "):)??(" + nameChar_ + ")"; private final String nameTest_ = "@?" + qName_; private final String kindTest_ = "schema-element\\(" + qName_ + "\\)"; @@ -105,8 +89,8 @@ public SchemaPath parse(String xpath, FeatureType rootNode, NamespaceContext nam schemaPath = new SchemaPath(); schemaPath.appendChild(rootNode); - xpath = xpath.trim().replaceAll("^/", ""); - String[] stepExprs = xpath.split("/", -1); + xpath = xpath.trim().replaceAll("^/+", ""); + List stepExprs = splitXPath(xpath); for (String stepExpr : stepExprs) { if (stepExpr.isEmpty()) @@ -495,4 +479,29 @@ else if ("false".equals(value)) return literal; } + private List splitXPath(String xpath) { + List tokens = new ArrayList<>(); + char beginStringLiteral = 0; + boolean isStringLiteral = false; + int offset = 0; + int next; + + for (next = 0; next < xpath.length(); next++) { + char ch = xpath.charAt(next); + if (ch == '\'' || ch == '"') { + if (!isStringLiteral) { + beginStringLiteral = ch; + isStringLiteral = true; + } else if (ch == beginStringLiteral) { + isStringLiteral = false; + } + } else if (ch == '/' && !isStringLiteral) { + tokens.add(xpath.substring(offset, next)); + offset = next + 1; + } + } + + tokens.add(xpath.substring(offset, next)); + return tokens; + } }