summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-04-20 13:13:04 (EDT)
committer pelder2006-04-20 13:13:04 (EDT)
commit6c5221eeca53d1b31d87725cc173001c6b8d2e16 (patch)
treebc408ab5877521b7c653ed024edb19fdbe0944f5
parentaae2e5ac0acbb2de74cd8cf4a563224d53bc11dd (diff)
downloadorg.eclipse.jet-6c5221eeca53d1b31d87725cc173001c6b8d2e16.zip
org.eclipse.jet-6c5221eeca53d1b31d87725cc173001c6b8d2e16.tar.gz
org.eclipse.jet-6c5221eeca53d1b31d87725cc173001c6b8d2e16.tar.bz2
[137584] Ensure dynamically loaded XSD schemas do not get registered with the global Package registry.
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/model/EMFModelLoader.java7
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/model/EMFXMLModelLoader.java7
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/SetTag.java2
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EObjectInspector.java71
-rw-r--r--tests/org.eclipse.jet.tests/data/beanModel.xml21
-rw-r--r--tests/org.eclipse.jet.tests/data/beanModel.xsd39
-rw-r--r--tests/org.eclipse.jet.tests/data/newproject.xml4
-rw-r--r--tests/org.eclipse.jet.tests/data/newproject.xsd81
-rw-r--r--tests/org.eclipse.jet.tests/data/plain.xml21
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/AllTests.java3
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/TestXMLDocumentLoads.java68
11 files changed, 295 insertions, 29 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/model/EMFModelLoader.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/model/EMFModelLoader.java
index 284d8b5..8def3d9 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/model/EMFModelLoader.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/model/EMFModelLoader.java
@@ -116,7 +116,12 @@ public class EMFModelLoader implements IModelLoader
ResourceSet resourceSet = getResourceSet();
final Resource.Factory factory = (Factory)resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().get(kind);
- Resource emfResource = factory.createResource(emfURI);
+
+ // add the URI's file extension to the resource set's factory registry, and create the resource
+ // via the resource set, otherwise, the resource is not part of the resource set !?!?
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(emfURI.fileExtension(), factory);
+// Resource emfResource = factory.createResource(emfURI);
+ Resource emfResource = resourceSet.createResource(emfURI);
Map options = getLoadOptions();
emfResource.load(options);
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/model/EMFXMLModelLoader.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/model/EMFXMLModelLoader.java
index b4fcf0c..7ee9d60 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/model/EMFXMLModelLoader.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/model/EMFXMLModelLoader.java
@@ -115,7 +115,12 @@ public class EMFXMLModelLoader implements IModelLoader
ResourceSet resourceSet = getResourceSet();
final Resource.Factory factory = (Factory)resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().get(XML_TYPE);
- Resource emfResource = factory.createResource(emfURI);
+
+ // add the URI's file extension to the resource set's factory registry, and create the resource
+ // via the resource set, otherwise, the resource is not part of the resource set !?!?
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(emfURI.fileExtension(), factory);
+// Resource emfResource = factory.createResource(emfURI);
+ Resource emfResource = resourceSet.createResource(emfURI);
Map options = getLoadOptions();
emfResource.load(options);
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/SetTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/SetTag.java
index d40e883..f384260 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/SetTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/SetTag.java
@@ -70,7 +70,7 @@ public class SetTag extends AbstractContainerTag
if (!isSet)
{
String msg = JET2Messages.SetTag_CoundNotSet;
- throw new JET2TagException(MessageFormat.format(msg, new Object []{ msg }));
+ throw new JET2TagException(MessageFormat.format(msg, new Object []{ name }));
}
}
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 071d69d..87a2660 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
@@ -62,7 +62,7 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
- protected final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData();
+ private final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData();
protected static final Object[] EMPTY_ARRAY = new Object []{};
@@ -74,6 +74,7 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
super();
}
+
/*
* (non-Javadoc)
*
@@ -82,14 +83,25 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
public Object[] getAttributes(Object contextNode)
{
EObject eObject = (EObject)contextNode;
+ return getAttributesInternal(eObject, false);
+ }
+
+
+ /**
+ * @param eObject
+ * @param includeUnsets TODO
+ * @return
+ */
+ private Object[] getAttributesInternal(EObject eObject, boolean includeUnsets)
+ {
// this is all the EStructuralFeatures that are explicitly tagged as
// attributes...
- List allAttributes = new ArrayList(extendedMetaData.getAllAttributes(eObject.eClass()));
+ List allAttributes = new ArrayList(getExtendedMetaData().getAllAttributes(eObject.eClass()));
// now add those EAttributes which don't have an explicit metadata...
for (Iterator i = eObject.eClass().getEAllAttributes().iterator(); i.hasNext();)
{
EAttribute attribute = (EAttribute)i.next();
- if (extendedMetaData.getFeatureKind(attribute) == ExtendedMetaData.UNSPECIFIED_FEATURE)
+ if (getExtendedMetaData().getFeatureKind(attribute) == ExtendedMetaData.UNSPECIFIED_FEATURE)
{
allAttributes.add(attribute);
}
@@ -101,9 +113,9 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
{
EStructuralFeature feature = (EStructuralFeature)i.next();
- if (eObject.eIsSet(feature))
+ if (eObject.eIsSet(feature) || includeUnsets)
{
- if (extendedMetaData.getFeatureKind(feature) == ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE)
+ if (getExtendedMetaData().getFeatureKind(feature) == ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE)
{
// this feature represents an anyAttribute wildcard, extract
// from the FeatureMap the actual attributes/features.
@@ -159,7 +171,7 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
// the extendedMetaData.getAttribute() fails to find schema-based
// attributes.
//
- Object[] allAttributeSettings = getAttributes(eObject);
+ Object[] allAttributeSettings = getAttributesInternal(eObject, true);
for (int i = 0; i < allAttributeSettings.length; i++)
{
EStructuralFeature.Setting setting = (EStructuralFeature.Setting)allAttributeSettings[i];
@@ -240,7 +252,7 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
*/
private ExpandedName expandedNameOfFeature(EStructuralFeature feature)
{
- ExpandedName featureEN = new ExpandedName(extendedMetaData.getNamespace(feature), feature.getName());
+ ExpandedName featureEN = new ExpandedName(getExtendedMetaData().getNamespace(feature), feature.getName());
return featureEN;
}
@@ -269,10 +281,10 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
return true;
}
- final EStructuralFeature feature = extendedMetaData.demandFeature(null, //"http://org.eclipse.jet/annotations",
+ final EStructuralFeature feature = getExtendedMetaData().demandFeature(null,
attributeName,
false);
- EStructuralFeature affiliation = extendedMetaData.getAffiliation(eClass, feature);
+ EStructuralFeature affiliation = getExtendedMetaData().getAffiliation(eClass, feature);
if (affiliation != null)
{
eObject.eSet(feature, value);
@@ -296,7 +308,7 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
// mostly EObjects map to ELEMENTs, but some EObjects are
// ATTRIBUTES.
// We check the extended meta data on the containing feature to see.
- switch (extendedMetaData.getFeatureKind(containingFeature))
+ switch (getExtendedMetaData().getFeatureKind(containingFeature))
{
case ExtendedMetaData.ATTRIBUTE_FEATURE:
case ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE:
@@ -304,7 +316,7 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
break;
}
}
- else if (EMPTY_STRING.equals(extendedMetaData.getName(eObject.eClass())))
+ else if (EMPTY_STRING.equals(getExtendedMetaData().getName(eObject.eClass())))
{
// it's a XML Document Root.
result = NodeKind.ROOT;
@@ -339,14 +351,14 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
EClass eClass = eObject.eClass();
if (isXMLNode(eClass))
{
- switch (extendedMetaData.getContentKind(eClass))
+ switch (getExtendedMetaData().getContentKind(eClass))
{
case ExtendedMetaData.UNSPECIFIED_CONTENT:
case ExtendedMetaData.EMPTY_CONTENT:
return EMPTY_STRING;
case ExtendedMetaData.SIMPLE_CONTENT:
{
- EStructuralFeature simpleFeature = extendedMetaData.getSimpleFeature(eClass);
+ EStructuralFeature simpleFeature = getExtendedMetaData().getSimpleFeature(eClass);
final Object rawValue = eObject.eGet(simpleFeature);
return stringValueOfFeature(simpleFeature, rawValue);
}
@@ -456,7 +468,7 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
if (isXMLNode(eClass))
{
- switch (extendedMetaData.getContentKind(eClass))
+ switch (getExtendedMetaData().getContentKind(eClass))
{
case ExtendedMetaData.UNSPECIFIED_CONTENT:
case ExtendedMetaData.EMPTY_CONTENT:
@@ -464,12 +476,12 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
return EMPTY_ARRAY;
case ExtendedMetaData.ELEMENT_ONLY_CONTENT:
{
- final List allElementsFeatures = extendedMetaData.getAllElements(eClass);
+ final List allElementsFeatures = getExtendedMetaData().getAllElements(eClass);
List result = new ArrayList(allElementsFeatures.size());
for (Iterator i = allElementsFeatures.iterator(); i.hasNext();)
{
EStructuralFeature feature = (EStructuralFeature)i.next();
- switch (extendedMetaData.getFeatureKind(feature))
+ switch (getExtendedMetaData().getFeatureKind(feature))
{
case ExtendedMetaData.ELEMENT_FEATURE:
if (feature instanceof EAttribute)
@@ -520,7 +532,7 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
}
case ExtendedMetaData.MIXED_CONTENT:
{
- EAttribute mixedFeature = extendedMetaData.getMixedFeature(eClass);
+ EAttribute mixedFeature = getExtendedMetaData().getMixedFeature(eClass);
FeatureMap featureMap = (FeatureMap)eObject.eGet(mixedFeature);
Object[] result = new Object [featureMap.size()];
int resultIndex = 0;
@@ -564,7 +576,7 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
for (EObject parent = eObject; parent != null; parent = parent.eContainer())
{
// we know document roots have an empty name in the extended metadata.
- if (EMPTY_STRING.equals(extendedMetaData.getName(parent.eClass())))
+ if (EMPTY_STRING.equals(getExtendedMetaData().getName(parent.eClass())))
{
return parent;
}
@@ -600,7 +612,7 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
Object root = getDocumentRoot(eObject);
if (root instanceof EObject)
{
- String namespace2 = extendedMetaData.getNamespace(feature);
+ String namespace2 = getExtendedMetaData().getNamespace(feature);
if (namespace2 == null)
{
nsPrefix = null;
@@ -609,7 +621,7 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
{
// it's a DocumentRoot, look up the namespace prefix map.
EObject rootEObject = (EObject)root;
- EReference prefixMapFeature = extendedMetaData.getXMLNSPrefixMapFeature(rootEObject.eClass());
+ EReference prefixMapFeature = getExtendedMetaData().getXMLNSPrefixMapFeature(rootEObject.eClass());
if (prefixMapFeature != null)
{
EcoreEMap xmlnsPrefixMap = (EcoreEMap)rootEObject.eGet(prefixMapFeature);
@@ -822,7 +834,7 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
private Object addElementToParent(EObject eParent, EStructuralFeature feature, Object newElement, Object addBeforeThisSibling)
{
// see if there is a feature map containing 'feature'
- EStructuralFeature affiliation = extendedMetaData.getAffiliation(eParent.eClass(), feature);
+ EStructuralFeature affiliation = getExtendedMetaData().getAffiliation(eParent.eClass(), feature);
if (FeatureMapUtil.isFeatureMap(affiliation))
{
FeatureMap fm = (FeatureMap)eParent.eGet(affiliation);
@@ -883,14 +895,14 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
String localName = elementName.getLocalPart();
if (isXMLNode(eClass))
{
- feature = extendedMetaData.getElement(eClass, elementNS, localName);
+ feature = getExtendedMetaData().getElement(eClass, elementNS, localName);
if (feature == null)
{
// generic XML processing creates features on the document root, look for them there...
- EStructuralFeature wildCardFeature = extendedMetaData.getElementWildcardAffiliation(eClass, elementNS, localName);
+ EStructuralFeature wildCardFeature = getExtendedMetaData().getElementWildcardAffiliation(eClass, elementNS, localName);
if (wildCardFeature != null)
{
- feature = extendedMetaData.demandFeature(elementNS, localName, true);
+ feature = getExtendedMetaData().demandFeature(elementNS, localName, true);
}
}
}
@@ -1009,7 +1021,7 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
if (feature.getEType() == EcorePackage.eINSTANCE.getEObject())
{
// it's a demand created type...
- EStructuralFeature affiliation = extendedMetaData.getAffiliation(eObject.eClass(), feature);
+ EStructuralFeature affiliation = getExtendedMetaData().getAffiliation(eObject.eClass(), feature);
AnyType newElement = XMLTypeFactory.eINSTANCE.createAnyType();
if(asCData)
@@ -1075,4 +1087,13 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
return en;
}
+
+ /**
+ * @return Returns the extendedMetaData.
+ */
+ private ExtendedMetaData getExtendedMetaData()
+ {
+ return extendedMetaData;
+ }
+
}
diff --git a/tests/org.eclipse.jet.tests/data/beanModel.xml b/tests/org.eclipse.jet.tests/data/beanModel.xml
new file mode 100644
index 0000000..fb8d74c
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/beanModel.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="beanModel.xsd">
+ <beanModel basePackage="org.example" name="Library">
+ <bean name="Library">
+ <attribute kind="FIELD" name="name" type="String"/>
+ <attribute kind="FIELD" name="yearFounded" type="int"/>
+ <attribute kind="DERIVED" name="yearsOpen" type="int"/>
+ <attribute kind="LIST" name="books" type="Book"/>
+ <attribute kind="LIST" name="authors" type="Author"/>
+ </bean>
+ <bean name="Book">
+ <attribute kind="FIELD" name="title" type="String"/>
+ <attribute kind="FIELD" name="pages" type="int"/>
+ <attribute kind="LIST" name="author" type="Author"/>
+ </bean>
+ <bean name="Author">
+ <attribute kind="FIELD" name="name" type="String"/>
+ <attribute kind="LIST" name="books" type="Book"/>
+ </bean>
+ </beanModel>
+</root>
diff --git a/tests/org.eclipse.jet.tests/data/beanModel.xsd b/tests/org.eclipse.jet.tests/data/beanModel.xsd
new file mode 100644
index 0000000..13a285a
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/beanModel.xsd
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:complexType name="root">
+ <xsd:sequence>
+ <xsd:element name="beanModel" type="beanModel" maxOccurs="unbounded" minOccurs="0"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="project">
+ <xsd:sequence>
+ <xsd:element name="beanModel" type="beanModel" maxOccurs="unbounded" minOccurs="0"></xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"></xsd:attribute>
+ </xsd:complexType>
+
+ <xsd:complexType name="beanModel">
+ <xsd:sequence>
+ <xsd:element name="bean" type="bean" maxOccurs="unbounded" minOccurs="0"></xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"></xsd:attribute>
+ <xsd:attribute name="basePackage" type="xsd:string"></xsd:attribute>
+ </xsd:complexType>
+
+ <xsd:complexType name="bean">
+ <xsd:sequence>
+ <xsd:element name="attribute" type="attribute" maxOccurs="unbounded" minOccurs="0"></xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"></xsd:attribute>
+ </xsd:complexType>
+
+ <xsd:complexType name="attribute">
+ <xsd:attribute name="name" type="xsd:string"></xsd:attribute>
+ <xsd:attribute name="type" type="xsd:string"></xsd:attribute>
+ <xsd:attribute name="kind" type="xsd:string"></xsd:attribute>
+ </xsd:complexType>
+
+ <xsd:element name="root" type="root"></xsd:element>
+</xsd:schema> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/data/newproject.xml b/tests/org.eclipse.jet.tests/data/newproject.xml
new file mode 100644
index 0000000..08c4b03
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/newproject.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<p:newProjectModel xmlns:p="org.eclipse.jet.transforms.newproject" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="org.eclipse.jet.transforms.newproject newproject.xsd ">
+ <project name="test3.foo.bar"/> <!-- HELLO -->
+</p:newProjectModel>
diff --git a/tests/org.eclipse.jet.tests/data/newproject.xsd b/tests/org.eclipse.jet.tests/data/newproject.xsd
new file mode 100644
index 0000000..55c11d1
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/newproject.xsd
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="org.eclipse.jet.transforms.newproject" xmlns="org.eclipse.jet.transforms.newproject">
+
+ <xsd:element name="newProjectModel" type="newProjectModel"></xsd:element>
+
+ <xsd:complexType name="newProjectModel">
+ <xsd:sequence minOccurs="1">
+ <xsd:element name="project" type="project" minOccurs="1"
+ maxOccurs="1">
+ </xsd:element>
+ <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="project">
+ <xsd:attribute name="name" type="xsd:string" use="required"></xsd:attribute>
+ <xsd:attribute name="bundleName" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>
+ The display name of the resulting JET project. If
+ not specified, this defaults to the value specified
+ in the 'name' parameter.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="bundleSymbolicName" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>
+ The id of the JET project. If not specified, this
+ defaults to the name of the project.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="bundleVersion" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>
+ The initial version number of the project. If not
+ specified, this defaults to 1.0.0.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="bundleVendor" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>
+ The Vendor of the JET Project. If not specified,
+ this defaults to the empty string.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="binDir" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>
+ The directory which will contain binary (compiled)
+ Java classes. If not specified, the default is
+ 'bin'.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="jet2javaDir" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>The directory into which Java source files corresponding to JET templates will be written. The default is 'jet2java'.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="templatesDir" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>The directory to which initial tempates will be written. The default if 'templates'.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="templateLoader" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>The fully qualified Java Class name of the template loader class. The default is 'org.eclipse.jet.compiled._jet_transformation'.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="startTemplate" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>The path of the start template. This path is relative the the tempates directory specified by templatesDir. The default is 'main.jet'.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:anyAttribute namespace="##other"></xsd:anyAttribute>
+ </xsd:complexType>
+</xsd:schema> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/data/plain.xml b/tests/org.eclipse.jet.tests/data/plain.xml
new file mode 100644
index 0000000..254246d
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/plain.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Root1>
+ <beanModel1 basePackage="org.example" name="Library">
+ <bean1 name="Library">
+ <attribute1 kind="FIELD" name="name" type="String"/>
+ <attribute1 kind="FIELD" name="yearFounded" type="int"/>
+ <attribute1 kind="DERIVED" name="yearsOpen" type="int"/>
+ <attribute1 kind="LIST" name="books" type="Book"/>
+ <attribute1 kind="LIST" name="authors" type="Author"/>
+ </bean1>
+ <bean1 name="Book">
+ <attribute1 kind="FIELD" name="title" type="String"/>
+ <attribute1 kind="FIELD" name="pages" type="int"/>
+ <attribute1 kind="LIST" name="author" type="Author"/>
+ </bean1>
+ <bean1 name="Author">
+ <attribute1 kind="FIELD" name="name" type="String"/>
+ <attribute1 kind="LIST" name="books" type="Book"/>
+ </bean1>
+ </beanModel1>
+</Root1> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/AllTests.java
index f2d2180..465fb9e 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/AllTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/AllTests.java
@@ -9,8 +9,9 @@ public class AllTests {
TestSuite suite = new TestSuite(
"Test for org.eclipse.jet.tests.model.load");
//$JUnit-BEGIN$
- suite.addTestSuite(EmfModelLoaderTests.class);
suite.addTestSuite(WorkspaceContextTests.class);
+ suite.addTestSuite(TestXMLDocumentLoads.class);
+ suite.addTestSuite(EmfModelLoaderTests.class);
//$JUnit-END$
return suite;
}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/TestXMLDocumentLoads.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/TestXMLDocumentLoads.java
new file mode 100644
index 0000000..db8e8e2
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/TestXMLDocumentLoads.java
@@ -0,0 +1,68 @@
+package org.eclipse.jet.tests.model.load;
+
+import java.io.IOException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.jet.internal.runtime.model.EMFXMLModelLoader;
+
+public class TestXMLDocumentLoads extends TestCase {
+
+
+ private EMFXMLModelLoader loader;
+
+ protected void setUp() throws Exception {
+ // TODO Auto-generated method stub
+ super.setUp();
+
+ loader = new EMFXMLModelLoader();
+ }
+
+ /**
+ * This test verifies the the XML Model loader does not put dynamically loaded
+ * XSD packages in the the default package registry. This is especially important
+ * for XSD schemas without a target namespace.
+ * @throws IOException
+ */
+ public void testOne() throws IOException {
+ testVerifyXMLLoadsDoNotAffectGlobalPackageRegistry();
+ }
+
+ /**
+ * This test verifies the the XML Model loader does not put dynamically loaded
+ * XSD packages in the the default package registry. This is especially important
+ * for XSD schemas without a target namespace.
+ * @throws IOException
+ */
+ public void testVerifyXMLLoadsDoNotAffectGlobalPackageRegistry() throws IOException {
+ final int pkgRegSz = EPackage.Registry.INSTANCE.size();
+
+ URL plainURL = new URL("platform:/plugin/org.eclipse.jet.tests/data/plain.xml");
+
+ final Object plainModel1 = loader.load(plainURL);
+ assertNotNull(plainModel1);
+
+ assertEquals(pkgRegSz, EPackage.Registry.INSTANCE.size());
+
+ URL newProjectURL = new URL("platform:/plugin/org.eclipse.jet.tests/data/newproject.xml");
+ final Object newProjectModel = loader.load(newProjectURL);
+ assertNotNull(newProjectModel);
+
+ assertEquals(pkgRegSz, EPackage.Registry.INSTANCE.size());
+
+ URL beanModelURL = new URL("platform:/plugin/org.eclipse.jet.tests/data/beanModel.xml");
+ final Object beanModel = loader.load(beanModelURL);
+ assertNotNull(beanModel);
+
+ assertEquals(pkgRegSz, EPackage.Registry.INSTANCE.size());
+
+ final Object plainModel2 = loader.load(plainURL);
+ assertNotNull(plainModel2);
+
+ assertEquals(pkgRegSz, EPackage.Registry.INSTANCE.size());
+
+
+ }
+}