Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2008-10-27 12:24:01 -0400
committerpelder2008-10-27 12:24:01 -0400
commit1ad09f92033b0e8f0b60cb6068ff76b7d8353b03 (patch)
tree8f82a5268a8bceff7db260d9cc64bb0a1d65c1ca
parent41903d83a7fd6d0ab44b06fffede7003d8e09a62 (diff)
downloadorg.eclipse.jet-1ad09f92033b0e8f0b60cb6068ff76b7d8353b03.tar.gz
org.eclipse.jet-1ad09f92033b0e8f0b60cb6068ff76b7d8353b03.tar.xz
org.eclipse.jet-1ad09f92033b0e8f0b60cb6068ff76b7d8353b03.zip
[252213] More than one level of substitution is not handled property in xpath engineR0_9_1_patch_001
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EObjectInspector.java28
-rw-r--r--tests/org.eclipse.jet.tests/data/substGroup/ReallySpecialChildren.xml8
-rw-r--r--tests/org.eclipse.jet.tests/data/substGroup/XMLSchemaWithGroups.xsd10
-rw-r--r--tests/org.eclipse.jet.tests/data/substGroup_2.4/ReallySpecialChildren.xml8
-rw-r--r--tests/org.eclipse.jet.tests/data/substGroup_2.4/XMLSchemaWithGroups.xsd11
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/AbstractSubstitutionGroupTests.java13
6 files changed, 72 insertions, 6 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EObjectInspector.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EObjectInspector.java
index 214fbd7..aa0aa77 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EObjectInspector.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EObjectInspector.java
@@ -143,16 +143,32 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
if(child instanceof EObject) {
final EObject eChild = (EObject)child;
final EReference containmentFeature = eChild.eContainmentFeature();
- final EStructuralFeature affiliation = exMD.getAffiliation(containmentFeature);
- final EStructuralFeature testFeature = affiliation != null ? affiliation : containmentFeature;
- if(expandedName.getLocalPart().equals(exMD.getName(testFeature))
- && (expandedName.getNamespaceURI() == null
- || expandedName.getNamespaceURI().equals(exMD.getNamespace(testFeature)))) {
- return true;
+ final List affiliations = getAffiliations(containmentFeature);
+ final List testFeatures = affiliations.size() > 0 ? affiliations : Collections.singletonList(containmentFeature);
+ for (Iterator i = testFeatures.iterator(); i.hasNext();)
+ {
+ final EStructuralFeature testFeature = (EStructuralFeature)i.next();
+ if(expandedName.getLocalPart().equals(exMD.getName(testFeature))
+ && (expandedName.getNamespaceURI() == null
+ || expandedName.getNamespaceURI().equals(exMD.getNamespace(testFeature)))) {
+ return true;
+ }
}
}
return false;
}
+
+ private List getAffiliations(EStructuralFeature feature)
+ {
+ List result = new ArrayList();
+
+ for (EStructuralFeature affiliation = exMD.getAffiliation(feature); affiliation != null; affiliation = exMD.getAffiliation(affiliation))
+ {
+ result.add(affiliation);
+ }
+
+ return result;
+ }
}
diff --git a/tests/org.eclipse.jet.tests/data/substGroup/ReallySpecialChildren.xml b/tests/org.eclipse.jet.tests/data/substGroup/ReallySpecialChildren.xml
new file mode 100644
index 0000000..f1e6f57
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/substGroup/ReallySpecialChildren.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tns:topElement xmlns:tns="http://www.example.org/XMLSchemaWithGroups" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/XMLSchemaWithGroups XMLSchemaWithGroups.xsd ">
+ <tns:child name="James"/>
+ <tns:specialChild name="Harry" specialNeed="Lots of Action"/>
+ <tns:reallySpecialChild name="Harry" specialNeed="Lots of Action" reallySpecialNeed="And candy"/>
+ <tns:child name="Lilly"/>
+ <tns:specialChild name="Dudley" specialNeed="Lots of Candy"/>
+</tns:topElement>
diff --git a/tests/org.eclipse.jet.tests/data/substGroup/XMLSchemaWithGroups.xsd b/tests/org.eclipse.jet.tests/data/substGroup/XMLSchemaWithGroups.xsd
index 77ec9da..edaf49d 100644
--- a/tests/org.eclipse.jet.tests/data/substGroup/XMLSchemaWithGroups.xsd
+++ b/tests/org.eclipse.jet.tests/data/substGroup/XMLSchemaWithGroups.xsd
@@ -33,4 +33,14 @@
</extension>
</complexContent>
</complexType>
+
+ <element name="reallySpecialChild" type="tns:ReallySpecialChildComplexType" substitutionGroup="tns:specialChild"></element>
+ <complexType name="ReallySpecialChildComplexType">
+ <complexContent>
+ <extension base="tns:SpecialChildComplexType">
+ <attribute name="reallySpecialNeed" type="string" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
</schema> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/data/substGroup_2.4/ReallySpecialChildren.xml b/tests/org.eclipse.jet.tests/data/substGroup_2.4/ReallySpecialChildren.xml
new file mode 100644
index 0000000..f1e6f57
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/substGroup_2.4/ReallySpecialChildren.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tns:topElement xmlns:tns="http://www.example.org/XMLSchemaWithGroups" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/XMLSchemaWithGroups XMLSchemaWithGroups.xsd ">
+ <tns:child name="James"/>
+ <tns:specialChild name="Harry" specialNeed="Lots of Action"/>
+ <tns:reallySpecialChild name="Harry" specialNeed="Lots of Action" reallySpecialNeed="And candy"/>
+ <tns:child name="Lilly"/>
+ <tns:specialChild name="Dudley" specialNeed="Lots of Candy"/>
+</tns:topElement>
diff --git a/tests/org.eclipse.jet.tests/data/substGroup_2.4/XMLSchemaWithGroups.xsd b/tests/org.eclipse.jet.tests/data/substGroup_2.4/XMLSchemaWithGroups.xsd
index b07e459..b0ff1a1 100644
--- a/tests/org.eclipse.jet.tests/data/substGroup_2.4/XMLSchemaWithGroups.xsd
+++ b/tests/org.eclipse.jet.tests/data/substGroup_2.4/XMLSchemaWithGroups.xsd
@@ -35,4 +35,15 @@
</extension>
</complexContent>
</complexType>
+
+ <element name="reallySpecialChild" type="tns:ReallySpecialChildComplexType" substitutionGroup="tns:specialChild"></element>
+ <complexType name="ReallySpecialChildComplexType">
+ <complexContent>
+ <extension base="tns:SpecialChildComplexType">
+ <attribute name="reallySpecialNeed" type="string" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+
</schema> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/AbstractSubstitutionGroupTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/AbstractSubstitutionGroupTests.java
index 9427616..735273f 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/AbstractSubstitutionGroupTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/AbstractSubstitutionGroupTests.java
@@ -112,6 +112,19 @@ public abstract class AbstractSubstitutionGroupTests extends TestCase {
assertEquals("result.size()", 0, result.size());
}
+ public void testReallySpecialChildren_schemaElement_child() throws XPathException, IOException {
+ final Object documentRoot = loadEMFXML("ReallySpecialChildren.xml");
+
+ final String xpath = "/topElement/_schema-element_child";
+
+ final XPathExpression compiledXPath = xpathEngine.compile(xpath);
+
+ Collection result = compiledXPath.evaluateAsNodeSet(documentRoot);
+
+ assertEquals("result.size()", 5, result.size());
+
+ }
+
private String getXPath(Object contextObject, String expression) throws XPathException {
final XPathExpression compiledExpression = xpathEngine.compile(expression);
return XPathUtil.xpathString(compiledExpression.evaluate(contextObject));

Back to the top