Commits

Anonymous committed db2832f

Changed code fragment handlings

  • Participants
  • Parent commits 7de2e0d

Comments (0)

Files changed (1)

File src/nl/tudelft/lime/xml/XMLFactory.java

     private static final String XLINK_FROM_ATTRIBUTE = "from";
     private static final String BOUND_TO_TAG = "bound-to";
     private static final String CODE_TAG = "code";
-    private static final String CONTEXT_ATTRIBUTE_TAG = "context";
+    private static final String CONTEXT_TAG = "context";
     private static final String ENDPOINT_TAG = "endpoint";
     private static final String EDGE_TAG = "edge";
     private static final String EDGES_TAG = "edges";
         //2. meta tag with id = "passthrough" : which would be the code part
         for (Element metaElement : metaElements) {
             //if it is the first case
-            if (metaElement.attribute("id").getValue().equals(META_TAG_VISUAL_ID)) {
-                subpart.setSizeByMap(getDimensionsListMap(metaElement.element(
+            if ((metaElement.attribute(ID_ATTRIBUTE) != null && metaElement.attributeValue(ID_ATTRIBUTE).equals(META_TAG_VISUAL_ID)) || 
+                (metaElement.element(ID_TAG) != null && metaElement.elementText(ID_TAG).equals(META_TAG_VISUAL_ID))) {
+            	subpart.setSizeByMap(getDimensionsListMap(metaElement.element(
                             SIZE_TAG)));
                 subpart.setLocationByMap(getDimensionsListMap(
                         metaElement.element(LOCATION_TAG)));
             }
             //if it is a code fragment
             else if (subpart instanceof LimeComponent &&
-                    metaElement.attribute("id").getValue()
-                                   .equals(META_TAG_CODE_ID)) {
+                    (metaElement.attribute(ID_ATTRIBUTE) != null && metaElement.attributeValue(ID_ATTRIBUTE).equals(META_TAG_CODE_ID)) || 
+                    (metaElement.element(ID_TAG) != null && metaElement.elementText(ID_TAG).equals(META_TAG_CODE_ID))) {
                 //create a label and make it as a child of this component
                 List<Element> codeElements = metaElement.elements(CODE_TAG);
                 
                 for (Element codeElement : codeElements){
                     LimeCodeFragment codeFragment = new LimeCodeFragment();
 	                codeFragment.setLabelContents((String) codeElement.getData());
-	                codeFragment.setContext((String) codeElement.attributeValue(CONTEXT_ATTRIBUTE_TAG));
+	                if (codeElement.attribute(CONTEXT_TAG) != null)
+	                	codeFragment.setContext((String) codeElement.attributeValue(CONTEXT_TAG));
+	                else
+	                	codeFragment.setContext((String) codeElement.elementText(CONTEXT_TAG));
 	                ((LimeComponent) subpart).addChild(codeFragment);
                 }
             }
 	            metaCode.add(codeFragmentElement);
 	
 	            codeFragmentElement.add(new DefaultCDATA(codeFragment.getLabelContents()));
-	            codeFragmentElement.add(new DefaultAttribute(CONTEXT_ATTRIBUTE_TAG, codeFragment.getContext()));
+	            codeFragmentElement.add(new DefaultAttribute(CONTEXT_TAG, codeFragment.getContext()));
 	            root.add(metaCode);
         	}
         }