Handle local references in QNameURIHandler.deresolve
Save only the fragment of local references, without the '#', in order
to produce a valid QName.
Additionally, fix some typos.
diff --git a/org.eclipse.bpmn2/src/org/eclipse/bpmn2/util/Bpmn2ResourceImpl.java b/org.eclipse.bpmn2/src/org/eclipse/bpmn2/util/Bpmn2ResourceImpl.java
index 2e1f383..c37d0e6 100644
--- a/org.eclipse.bpmn2/src/org/eclipse/bpmn2/util/Bpmn2ResourceImpl.java
+++ b/org.eclipse.bpmn2/src/org/eclipse/bpmn2/util/Bpmn2ResourceImpl.java
@@ -138,7 +138,7 @@
*/
protected class BpmnXmlHelper extends XMLHelperImpl {
- private Definitions defintions;
+ private Definitions definitions;
private String targetNsPrefix;
public BpmnXmlHelper(Bpmn2ResourceImpl resource) {
@@ -152,7 +152,7 @@
public void setValue(EObject object, EStructuralFeature feature, Object value, int position) {
super.setValue(object, feature, value, position);
if (object instanceof Definitions) {
- this.defintions = (Definitions) object;
+ this.definitions = (Definitions) object;
if (feature.equals(Bpmn2Package.Literals.DEFINITIONS__TARGET_NAMESPACE)) {
this.targetNsPrefix = getPrefix((String) value);
}
@@ -161,12 +161,12 @@
}
/**
- * Checks of the given prefix is pointing to the current target namespace and thus is optional.
+ * Checks if the given prefix is pointing to the current target namespace and thus is optional.
* The method is called during load.
* @param prefix
* @return
*/
- public boolean isTargnetNamespace(String prefix) {
+ public boolean isTargetNamespace(String prefix) {
return prefix.equals(this.targetNsPrefix);
}
@@ -179,7 +179,7 @@
public String getPathForPrefix(String prefix) {
String ns = this.getNamespaceURI(prefix);
if (ns != null) {
- for (Import imp : this.defintions.getImports()) {
+ for (Import imp : this.definitions.getImports()) {
if (ns.equals(imp.getNamespace())) {
// TODO: Also check that imp.getType() is BPMN
return imp.getLocation();
@@ -221,7 +221,7 @@
public String getNsPrefix(String filePath) {
String ns = null;
String prefix = "";
- for (Import imp : this.defintions.getImports()) {
+ for (Import imp : this.definitions.getImports()) {
if (filePath.equals(imp.getLocation())) {
// TODO: Also check that imp.getType() is BPMN
ns = imp.getNamespace();
diff --git a/org.eclipse.bpmn2/src/org/eclipse/bpmn2/util/QNameURIHandler.java b/org.eclipse.bpmn2/src/org/eclipse/bpmn2/util/QNameURIHandler.java
index 48d3ea7..05c7f3f 100644
--- a/org.eclipse.bpmn2/src/org/eclipse/bpmn2/util/QNameURIHandler.java
+++ b/org.eclipse.bpmn2/src/org/eclipse/bpmn2/util/QNameURIHandler.java
@@ -40,7 +40,7 @@
/**
* The method converts a QName, e.g. "ns:element1" to a URI string, e.g. file1.bpmn#element1.
- * The method os called during load.
+ * The method is called during load.
* @param qName
* @return
*/
@@ -55,7 +55,7 @@
String[] parts = qName.split(":");
if (parts.length > 1) {
fragment = parts[1];
- if (!xmlHelper.isTargnetNamespace(parts[0])) {
+ if (!xmlHelper.isTargetNamespace(parts[0])) {
path = xmlHelper.getPathForPrefix(parts[0]);
}
}
@@ -78,8 +78,8 @@
@Override
public URI deresolve(URI uri) {
URI deresolved = super.deresolve(uri);
- String frament = deresolved.fragment();
- if (!frament.startsWith("/")) // We better don't try to QName XPath references to e.g. XML or WSDL context for now.
+ String fragment = deresolved.fragment();
+ if (!fragment.startsWith("/")) // We better don't try to QName XPath references to e.g. XML or WSDL context for now.
{
String prefix = "";
@@ -87,8 +87,10 @@
prefix = xmlHelper.getNsPrefix(deresolved.trimFragment().toString());
}
if (prefix.length() > 0) {
- return URI.createURI(prefix + ":" + frament);
- }
+ return URI.createURI(prefix + ":" + fragment);
+ } else
+ // no prefix, just fragment (i.e. without the '#')
+ return URI.createURI(fragment);
}
return deresolved;
}