Changeset 623
- Timestamp:
- 11/15/12 14:48:01 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/trunk/src/test/DEBBTranslator/src/test/DEBBTranslator/src/DEBB2DCWoRMSTranslator.java
r617 r623 11 11 import javax.xml.parsers.ParserConfigurationException; 12 12 import javax.xml.transform.OutputKeys; 13 import javax.xml.transform.Source;14 13 import javax.xml.transform.Transformer; 15 14 import javax.xml.transform.TransformerConfigurationException; … … 65 64 private static XPath xpath; 66 65 private static Document dcwormsDocument; 67 private static Logger logger = Logger.getLogger(DEBB2DCWoRMSTranslator.class); 66 private static Logger logger = Logger 67 .getLogger(DEBB2DCWoRMSTranslator.class); 68 68 private static StreamSource xsltDEBBComponentTransformationSource; 69 69 private static Transformer xsltDEBBComponentTransformationTransformer; 70 70 71 71 /** 72 72 * … … 85 85 if (args != null && args.length > 0) { 86 86 inputFileName = args[0]; 87 if (inputFileName == null || (inputFileName != null && inputFileName.isEmpty() == true)) { 87 if (inputFileName == null 88 || (inputFileName != null && inputFileName.isEmpty() == true)) { 88 89 inputFileName = DEFAULT_PLMXML_INPUT_FILE_NAME; 89 90 } … … 91 92 if (args.length > 1) { 92 93 outputFileName = args[1]; 93 if (outputFileName == null || (outputFileName != null && outputFileName.isEmpty() == true)) { 94 if (outputFileName == null 95 || (outputFileName != null && outputFileName.isEmpty() == true)) { 94 96 outputFileName = DEFAULT_DCWORMS_OUTPUT_FILE_NAME; 95 97 } … … 97 99 } 98 100 BasicConfigurator.configure(); 99 101 100 102 logger.debug("inputFileName=" + inputFileName); 101 103 logger.debug("outputFileName=" + outputFileName); 102 103 104 104 105 105 try { 106 106 initialize(); … … 187 187 } 188 188 189 private static void initialize() throws ParserConfigurationException, TransformerConfigurationException { 189 private static void initialize() throws ParserConfigurationException, 190 TransformerConfigurationException { 190 191 domFactory = DocumentBuilderFactory.newInstance(); 191 192 domFactory.setNamespaceAware(true); // never forget this! … … 197 198 xmlDocumentBuilder = domFactory.newDocumentBuilder(); 198 199 199 // XSLT transformation for translating information stored DEBB Components file(s) 200 // XSLT transformation for translating information stored DEBB 201 // Components file(s) 200 202 xsltDEBBComponentTransformationSource = new StreamSource( 201 203 DEFAULT_DEBB_COMPONENT_TRANSFORMATION_FILE_NAME); 202 204 // create an instance of TransformerFactory 203 TransformerFactory transFact = TransformerFactory.newInstance(); 205 TransformerFactory transFact = TransformerFactory.newInstance(); 204 206 xsltDEBBComponentTransformationTransformer = transFact 205 .newTransformer(xsltDEBBComponentTransformationSource);206 207 .newTransformer(xsltDEBBComponentTransformationSource); 208 207 209 // TODO: Check it this is correct! 208 210 // TODO: Move it to configuration file … … 427 429 428 430 // ***************************************************************** 429 // 4) Translation of information about DEBB taken from corresponding DEBB components file 431 // 4) Translation of information about DEBB taken from corresponding 432 // DEBB components file 430 433 try { 431 // Each DEBB can be described in separate document 432 // DOMSource -> DOMResult 434 // Each DEBB can be described in separate document 435 // DOMSource -> DOMResult 436 // Starting parsing DEBB Components document from specified node 437 // works fine with Saxon, but doesn't with Xalan 433 438 DOMSource domSource = new DOMSource(debbComponentNode); 434 439 DOMResult domResult = new DOMResult(computingResourceElement); 435 440 436 437 438 439 xsltDEBBComponentTransformationTransformer.transform(domSource, domResult); 440 logger.debug("result node=" 441 + domResult.getNode().getNodeName()); 441 xsltDEBBComponentTransformationTransformer.transform(domSource, 442 domResult); 443 logger.debug("result node=" + domResult.getNode().getNodeName()); 442 444 } catch (NullPointerException npEx) { 443 logger.info("Cannot find debb " + debbComponentIdNode.getNodeValue() + " in corresponding DEBB Components file"); 444 } 445 446 // 5) Adding several minor details about DEBB stored in PLM XML document: 447 // Name of the host 445 logger.info("Cannot find debb " 446 + debbComponentIdNode.getNodeValue() 447 + " in corresponding DEBB Components " 448 + debbComponentFileName + " file"); 449 } 450 451 // 5) Adding several minor details about DEBB stored in PLM XML 452 // document: 453 // Name of the host 448 454 if (debbHostNameNode != null) { 449 455 Element parameterElement = dcwormsDocument … … 460 466 } 461 467 462 // 468 // Sequence 463 469 if (debbSequenceNode != null) { 464 470 // TODO: Sequence is described unclearly in the deliverable, not … … 478 484 debbParentElement.appendChild(computingResourceElement); 479 485 480 // 486 // Label 481 487 if (debbLabelNode != null) { 482 488 Element parameterElement = dcwormsDocument … … 494 500 } 495 501 496 // 502 // Location 497 503 if (debbLocationNode != null) { 498 504 Element parameterElement = dcwormsDocument … … 508 514 computingResourceElement.appendChild(parameterElement); 509 515 } 510 511 516 512 517 // *****************************************************************
Note: See TracChangeset
for help on using the changeset viewer.