Index: DCWoRMS/trunk/src/test/DEBBTranslator/src/DEBB2DCWoRMSTranslator.java
===================================================================
--- DCWoRMS/trunk/src/test/DEBBTranslator/src/DEBB2DCWoRMSTranslator.java	(revision 586)
+++ DCWoRMS/trunk/src/test/DEBBTranslator/src/DEBB2DCWoRMSTranslator.java	(revision 602)
@@ -8,10 +8,13 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
@@ -25,5 +28,4 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 
@@ -48,4 +50,6 @@
 	private static final String DEFAULT_PLMXML_INPUT_FILE_NAME = "xml/PLMXML_HLRSSmallServerRoom.xml";
 	private static final String DEFAULT_DEBB_COMPONENT_INPUT_FILE_NAME = "xml/DEBBComponents.xml";
+	private static final String DEFAULT_SCHEMA_NAME = "DCWormsResSchema.xsd";
+	private static final String DEFAULT_DEBB_COMPONENT_TRANSFORMATION_FILE_NAME = "xml/DEBBComponentTranslator.xsl";
 	private static DocumentBuilder xmlDocumentBuilder;
 	private static DocumentBuilderFactory domFactory;
@@ -103,10 +107,18 @@
 			// Creating destination, dcworms document
 			dcwormsDocument = xmlDocumentBuilder.newDocument();
+
 			// Creating root, environment, element
 			Element rootElement = dcwormsDocument.createElement("environment");
+
+			// Attr namespaceAttribute = dcwormsDocument
+			// .createAttribute("xsi:noNamespaceSchemaLocation");
+			// namespaceAttribute.setValue(DEFAULT_SCHEMA_NAME);
+			// rootElement.setAttributeNode(namespaceAttribute);
 			dcwormsDocument.appendChild(rootElement);
 			Comment comment = dcwormsDocument
 					.createComment("CoolEmAll testbed description");
 			rootElement.appendChild(comment);
+			// rootElement.setAttributeNS("http://www.w3.org/2001/XMLSchema-instance",
+			// "xmlns:xsi", "value");
 
 			// Creating resources element
@@ -130,6 +142,6 @@
 
 			// *****************************************************************
-			//	TODO: Extract information about sensors from PLM XML
-			
+			// TODO: Extract information about sensors from PLM XML
+
 			// write the content into xml file
 			saveDCWoRMSOutputFile(outputFileName, dcwormsDocument);
@@ -283,7 +295,7 @@
 		System.out.println("partRef=" + partRefNode.getNodeValue());
 		String partId = partRefNode.getNodeValue().substring(1); // Get rid of #
-																	// at
-																	// the
-																	// beginning
+		// at
+		// the
+		// beginning
 		// UserData - hostname
 		expr = xpath
@@ -427,11 +439,11 @@
 				parameterElement.appendChild(valueElement);
 				computingResourceElement.appendChild(parameterElement);
-
 			}
 
 			// *****************************************************************
-			// Read data from DEBBComponent file(s)
-/*			Document debbComponentDocument = readDEBBComponentInputFile(debbComponentFileName);
-			System.out.println(debbComponentIdNode.getNodeValue());
+
+			Document debbComponentDocument = readDEBBComponentInputFile(debbComponentFileName);
+			System.out.println("debbComponentNode="
+					+ debbComponentIdNode.getNodeValue());
 			expr = xpath.compile("//*[ComponentId='"
 					+ debbComponentIdNode.getNodeValue() + "']");
@@ -439,25 +451,27 @@
 			Node debbComponentNode = (Node) result;
 			if (debbComponentNode != null) {
-				System.out.println("id=" + debbComponentNode.getNodeName());
-
-				// Get all processors
-				transformProcessors(debbComponentNode, computingResourceElement);
-
-				// Get all memory units
-				transformMemoryUnits(debbComponentNode,
-						computingResourceElement);
-
-				// Get all storages
-				transformStorages(debbComponentNode, computingResourceElement);
-
-				// Get all cooling devices
-				transformCoolingDevices(debbComponentNode,
-						computingResourceElement);
-				// Get all baseboards
-				transformBaseboards(debbComponentNode, computingResourceElement);
-				// Get all sensors
-				transformSensors(debbComponentNode, computingResourceElement);
-			}
-*/
+				System.out.println("debbComponentNode="
+						+ debbComponentNode.getNodeName());
+			}
+			// DOMSource/DOMResult
+			try {
+//				DOMSource domSource = new DOMSource(debbParentElement);
+				DOMSource domSource = new DOMSource(computingResourceElement);
+				Source xsltSource = new StreamSource(
+						DEFAULT_DEBB_COMPONENT_TRANSFORMATION_FILE_NAME);
+				DOMResult domResult = new DOMResult(computingResourceElement);
+				// create an instance of TransformerFactory
+				TransformerFactory transFact = TransformerFactory.newInstance();
+
+				javax.xml.transform.Transformer trans = transFact
+						.newTransformer(xsltSource);
+
+				trans.transform(domSource, domResult);
+				System.out.println("result node=" + domResult.getNode().getNodeName());
+			} catch (NullPointerException npEx) {
+				System.out.println("NullPointerException on debb "
+						+ debbComponentIdNode.getNodeValue());
+			}
+
 			// Find component
 
@@ -484,171 +498,3 @@
 		}
 	}
-
-	private static void transformCoolingDevices(Node debbComponentNode,
-			Element computingResourceElement) throws XPathExpressionException {
-		XPathExpression expr = xpath.compile("CoolingDevice");
-		Object result = expr
-				.evaluate(debbComponentNode, XPathConstants.NODESET);
-		NodeList coolingDeviceNodeList = (NodeList) result;
-		if (coolingDeviceNodeList != null) {
-			for (int i = 0; i < coolingDeviceNodeList.getLength(); i++) {
-				Node coolingDeviceNode = coolingDeviceNodeList.item(i);
-
-				Element resourceUnitElement = dcwormsDocument
-						.createElement("resourceUnit");
-				Attr coolingDeviceClassAttribute = dcwormsDocument
-						.createAttribute("class");
-				coolingDeviceClassAttribute.setValue(resourceUnitClasses
-						.get(coolingDeviceNode.getNodeName()));
-				resourceUnitElement
-						.setAttributeNode(coolingDeviceClassAttribute);
-				computingResourceElement.appendChild(resourceUnitElement);
-			}
-		}
-
-	}
-
-	private static void transformProcessors(Node debbComponentNode,
-			Element computingResourceElement) throws XPathExpressionException {
-		XPathExpression expr = xpath.compile("Processor");
-		Object result = expr
-				.evaluate(debbComponentNode, XPathConstants.NODESET);
-		NodeList processorNodeList = (NodeList) result;
-		if (processorNodeList != null) {
-			for (int i = 0; i < processorNodeList.getLength(); i++) {
-				Node processorNode = processorNodeList.item(i);
-
-				Element processorElement = dcwormsDocument
-						.createElement("computingResource");
-				Attr processorClassAttribute = dcwormsDocument
-						.createAttribute("class");
-				processorClassAttribute.setValue(computingResourceClasses
-						.get(processorNode.getNodeName()));
-				processorElement.setAttributeNode(processorClassAttribute);
-//
-//				// Device attributes
-//				NodeList parameterNodes = processorNode.getChildNodes();
-//				String tmp = "";
-//				for (int j = 0; j < parameterNodes.getLength(); j++) {
-//					Node child = parameterNodes.item(j);
-//
-//					short type = child.getNodeType();
-//					System.out.println("type=" + type);
-//					if (type == Node.ELEMENT_NODE) {
-//						Element parameterElement = dcwormsDocument
-//								.createElement("parameter");
-//						Attr parameterNameAttribute = dcwormsDocument
-//								.createAttribute("name");
-//						parameterNameAttribute.setValue(child.getNodeName());
-//						parameterElement
-//								.setAttributeNode(parameterNameAttribute);
-//						Element valueElement = dcwormsDocument
-//								.createElement("value");
-//						valueElement.appendChild(dcwormsDocument
-//								.createTextNode(tmp));
-//						parameterElement.appendChild(valueElement);
-//						computingResourceElement.appendChild(parameterElement);
-//
-//					} else if (type == Node.TEXT_NODE) {
-//						tmp = child.getNodeValue();
-//
-//					}
-//
-//				}
-			}
-		}
-
-	}
-
-	private static void transformSensors(Node debbComponentNode,
-			Element computingResourceElement) throws XPathExpressionException {
-
-		// TODO: Take them from PLM XML
-		/*
-		 * XPathExpression expr = xpath.compile("Sensor"); Object result =
-		 * expr.evaluate(debbComponentNode, XPathConstants.NODESET); NodeList
-		 * sensorsNodeList = (NodeList) result; if (sensorsNodeList != null) {
-		 * for (int i = 0; i < sensorsNodeList.getLength(); i++) { Node
-		 * sensorNode = sensorsNodeList.item(i);
-		 * 
-		 * Element resourceUnitElement = dcwormsDocument
-		 * .createElement("resourceUnit"); Attr sensorClassAttribute =
-		 * dcwormsDocument.createAttribute("class");
-		 * sensorClassAttribute.setValue
-		 * (resourceUnitClasses.get(sensorNode.getNodeName()));
-		 * resourceUnitElement.setAttributeNode(sensorClassAttribute);
-		 * computingResourceElement .appendChild(resourceUnitElement); } }
-		 */
-
-	}
-
-	private static void transformStorages(Node debbComponentNode,
-			Element computingResourceElement) throws XPathExpressionException {
-		XPathExpression expr = xpath.compile("Storage");
-		Object result = expr
-				.evaluate(debbComponentNode, XPathConstants.NODESET);
-		NodeList storageNodeList = (NodeList) result;
-		if (storageNodeList != null) {
-			for (int i = 0; i < storageNodeList.getLength(); i++) {
-				Node storageNode = storageNodeList.item(i);
-
-				Element resourceUnitElement = dcwormsDocument
-						.createElement("resourceUnit");
-				Attr storageClassAttribute = dcwormsDocument
-						.createAttribute("class");
-				storageClassAttribute.setValue(resourceUnitClasses
-						.get(storageNode.getNodeName()));
-				resourceUnitElement.setAttributeNode(storageClassAttribute);
-				computingResourceElement.appendChild(resourceUnitElement);
-			}
-		}
-
-	}
-
-	private static void transformMemoryUnits(Node debbComponentNode,
-			Element computingResourceElement) throws XPathExpressionException {
-		XPathExpression expr = xpath.compile("Memory");
-		Object result = expr
-				.evaluate(debbComponentNode, XPathConstants.NODESET);
-		NodeList memoryNodeList = (NodeList) result;
-		if (memoryNodeList != null) {
-			for (int i = 0; i < memoryNodeList.getLength(); i++) {
-				Node memoryNode = memoryNodeList.item(i);
-
-				Element resourceUnitElement = dcwormsDocument
-						.createElement("resourceUnit");
-				Attr memoryClassAttribute = dcwormsDocument
-						.createAttribute("class");
-				memoryClassAttribute.setValue(resourceUnitClasses
-						.get(memoryNode.getNodeName()));
-				resourceUnitElement.setAttributeNode(memoryClassAttribute);
-				computingResourceElement.appendChild(resourceUnitElement);
-			}
-		}
-	}
-
-	private static void transformBaseboards(Node debbComponentNode,
-			Element computingResourceElement) throws XPathExpressionException {
-
-		XPathExpression expr = xpath.compile("Baseboard");
-		Object result = expr
-				.evaluate(debbComponentNode, XPathConstants.NODESET);
-		NodeList baseboardNodeList = (NodeList) result;
-		if (baseboardNodeList != null) {
-			for (int i = 0; i < baseboardNodeList.getLength(); i++) {
-				Node baseboardNode = baseboardNodeList.item(i);
-
-				Element resourceUnitElement = dcwormsDocument
-						.createElement("resourceUnit");
-				Attr baseboardClassAttribute = dcwormsDocument
-						.createAttribute("class");
-				baseboardClassAttribute.setValue(resourceUnitClasses
-						.get(baseboardNode.getNodeName()));
-				resourceUnitElement.setAttributeNode(baseboardClassAttribute);
-				computingResourceElement.appendChild(resourceUnitElement);
-			}
-		}
-
-	}
-
 }
