Changeset 617 for DCWoRMS/trunk/src


Ignore:
Timestamp:
11/15/12 08:33:43 (12 years ago)
Author:
gosiaw
Message:

Opening xslt transformation once

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/trunk/src/test/DEBBTranslator/src/test/DEBBTranslator/src/DEBB2DCWoRMSTranslator.java

    r616 r617  
    6666        private static Document dcwormsDocument; 
    6767        private static Logger logger = Logger.getLogger(DEBB2DCWoRMSTranslator.class); 
     68        private static StreamSource xsltDEBBComponentTransformationSource; 
     69        private static Transformer xsltDEBBComponentTransformationTransformer; 
    6870         
    6971        /** 
     
    185187        } 
    186188 
    187         private static void initialize() throws ParserConfigurationException { 
     189        private static void initialize() throws ParserConfigurationException, TransformerConfigurationException { 
    188190                domFactory = DocumentBuilderFactory.newInstance(); 
    189191                domFactory.setNamespaceAware(true); // never forget this! 
     
    195197                xmlDocumentBuilder = domFactory.newDocumentBuilder(); 
    196198 
     199                //      XSLT transformation for translating information stored DEBB Components file(s) 
     200                xsltDEBBComponentTransformationSource = new StreamSource( 
     201                                DEFAULT_DEBB_COMPONENT_TRANSFORMATION_FILE_NAME); 
     202                // create an instance of TransformerFactory 
     203                TransformerFactory transFact = TransformerFactory.newInstance();                 
     204                xsltDEBBComponentTransformationTransformer = transFact 
     205                .newTransformer(xsltDEBBComponentTransformationSource); 
     206                 
    197207                // TODO: Check it this is correct! 
    198208                // TODO: Move it to configuration file 
     
    390400 
    391401                // ***************************************************************** 
    392                 // Add computingResource element for the DEBB 
     402                // 3) Add computingResource element for the DEBB 
    393403                if (debbLevelNode != null) { 
    394404                        Element computingResourceElement = dcwormsDocument 
     
    417427 
    418428                        // ***************************************************************** 
    419                         //      Translation of information about debb taken from DEBB components file 
    420                         // DOMSource/DOMResult 
     429                        //      4) Translation of information about DEBB taken from corresponding DEBB components file 
    421430                        try { 
    422                                 // DOMSource domSource = new DOMSource(debbParentElement); 
     431                                //      Each DEBB can be described in separate document 
     432                                //      DOMSource -> DOMResult 
    423433                                DOMSource domSource = new DOMSource(debbComponentNode); 
    424                                 Source xsltSource = new StreamSource( 
    425                                                 DEFAULT_DEBB_COMPONENT_TRANSFORMATION_FILE_NAME); 
    426434                                DOMResult domResult = new DOMResult(computingResourceElement); 
    427                                 // StreamResult systemOutResult = new StreamResult(System.out); 
    428                                 // create an instance of TransformerFactory 
    429                                 TransformerFactory transFact = TransformerFactory.newInstance(); 
    430  
    431                                 javax.xml.transform.Transformer trans = transFact 
    432                                                 .newTransformer(xsltSource); 
    433  
    434                                 trans.transform(domSource, domResult); 
     435 
     436 
     437 
     438 
     439                                xsltDEBBComponentTransformationTransformer.transform(domSource, domResult); 
    435440                                logger.debug("result node=" 
    436441                                                + domResult.getNode().getNodeName()); 
     
    439444                        } 
    440445 
     446                        //      5) Adding several minor details about DEBB stored in PLM XML document: 
     447                        //      Name of the host 
    441448                        if (debbHostNameNode != null) { 
    442449                                Element parameterElement = dcwormsDocument 
     
    453460                        } 
    454461 
     462                        //      Sequence 
    455463                        if (debbSequenceNode != null) { 
    456464                                // TODO: Sequence is described unclearly in the deliverable, not 
     
    470478                        debbParentElement.appendChild(computingResourceElement); 
    471479 
     480                        //      Label 
    472481                        if (debbLabelNode != null) { 
    473482                                Element parameterElement = dcwormsDocument 
     
    485494                        } 
    486495 
     496                        //      Location 
    487497                        if (debbLocationNode != null) { 
    488498                                Element parameterElement = dcwormsDocument 
     
    499509                        } 
    500510 
     511 
    501512                        // ***************************************************************** 
    502  
    503                         // Find component 
    504  
    505                         // ***************************************************************** 
    506                         // Get nested instances - nested DEBBs and ask them to transform 
     513                        // 6) Get nested instances - nested DEBBs and ask them to transform 
    507514                        // themselves 
    508515                        Node instanceRefsNode = productRevisionViewNode.getAttributes() 
Note: See TracChangeset for help on using the changeset viewer.