Revision: 17153
          http://sourceforge.net/p/gate/code/17153
Author:   markagreenwood
Date:     2013-12-01 16:43:15 +0000 (Sun, 01 Dec 2013)
Log Message:
-----------
added support for the include element to make it easier to load multiple schemas

Modified Paths:
--------------
    gate/trunk/src/main/gate/creole/AnnotationSchema.java

Modified: gate/trunk/src/main/gate/creole/AnnotationSchema.java
===================================================================
--- gate/trunk/src/main/gate/creole/AnnotationSchema.java       2013-12-01 
15:53:42 UTC (rev 17152)
+++ gate/trunk/src/main/gate/creole/AnnotationSchema.java       2013-12-01 
16:43:15 UTC (rev 17153)
@@ -23,6 +23,9 @@
 import org.jdom.Namespace;
 import org.jdom.input.SAXBuilder;
 
+import gate.Factory;
+import gate.FeatureMap;
+import gate.Gate;
 import gate.Resource;
 import gate.creole.metadata.CreoleParameter;
 import gate.creole.metadata.CreoleResource;
@@ -121,7 +124,13 @@
       setUpStaticData();
 
     // parse the XML file if we have its URL
-    if(xmlFileUrl != null) fromXSchema(xmlFileUrl);
+    if(xmlFileUrl != null) {
+      fromXSchema(xmlFileUrl);
+      
+      if (annotationName == null) {
+        Gate.setHiddenAttribute(getFeatures(), true);
+      }
+    }    
 
     return this;
   } // init()
@@ -186,11 +195,13 @@
     * @param jDom the JDOM structure containing the XSchema document. It must 
not
     * be <b>null<b>
     */
-  private void workWithJDom(org.jdom.Document jDom){
+  private void workWithJDom(org.jdom.Document jDom) throws 
ResourceInstantiationException {
     // Use the jDom structure the way we want
     org.jdom.Element rootElement = jDom.getRootElement();
     namespace = rootElement.getNamespace();
+    
     // get all children elements from the rootElement
+    //TODO if there is more than one throw an exception as they will overwrite 
each other
     List rootElementChildrenList = rootElement.getChildren("element", 
namespace);
     Iterator rootElementChildrenIterator = rootElementChildrenList.iterator();
     while (rootElementChildrenIterator.hasNext()){
@@ -198,6 +209,24 @@
                         (org.jdom.Element) rootElementChildrenIterator.next();
       createAnnotationSchemaObject(childElement);
     }//end while
+    
+    rootElementChildrenList = rootElement.getChildren("include", namespace);
+    rootElementChildrenIterator = rootElementChildrenList.iterator();
+    while (rootElementChildrenIterator.hasNext()){
+      org.jdom.Element childElement =
+              (org.jdom.Element) rootElementChildrenIterator.next();
+      
+      try {
+          String url = childElement.getAttributeValue("schemaLocation");
+          FeatureMap params = Factory.newFeatureMap();
+          params.put("xmlFileUrl", new URL(xmlFileUrl,url));
+      
+          Factory.createResource("gate.creole.AnnotationSchema", params);
+      }
+      catch (Exception e) {
+        throw new ResourceInstantiationException(e);
+      }
+    }
   } // workWithJdom
 
   /** This method creates an AnnotationSchema object fom an org.jdom.Element

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to