Package com.dotcms.repackage.javax.xml.transform

Examples of com.dotcms.repackage.javax.xml.transform.Source


      if(!canUserEvalute()){
        Logger.error(XsltTool.class, "XSLTTool user does not have scripting access ");
        return null;
      }
      String outputXML = null;
      Source xmlSource = null;
      XSLTranformationDoc doc = null;
      Host host = hostWebAPI.getCurrentHost(request);

      /*Validate if in cache exists a valid version*/
      doc = XSLTransformationCache.getXSLTranformationDocByXMLPath(XMLPath,XSLPath);

      if(doc == null){
        /*Get the XSL source*/
        java.io.File binFile = null;
        Identifier xslId = APILocator.getIdentifierAPI().find(host, XSLPath);
        if(xslId!=null && InodeUtils.isSet(xslId.getId()) && xslId.getAssetType().equals("contentlet")){
          Contentlet cont = APILocator.getContentletAPI().findContentletByIdentifier(xslId.getId(), true, APILocator.getLanguageAPI().getDefaultLanguage().getId(), userAPI.getSystemUser(),false);
          if(cont!=null && InodeUtils.isSet(cont.getInode())){
            binFile = cont.getBinary(FileAssetAPI.BINARY_FIELD);
          }
        }else{
          File xslFile = fileAPI.getFileByURI(XSLPath, host, true, userAPI.getSystemUser(),false);
          binFile = fileAPI.getAssetIOFile (xslFile);
        }
       
       
        /*Get the XML Source from file or from URL*/
        if(!XMLPath.startsWith("http")){
          Identifier xmlId = APILocator.getIdentifierAPI().find(host, XMLPath);
          if(xmlId!=null && InodeUtils.isSet(xmlId.getId()) && xmlId.getAssetType().equals("contentlet")){
            Contentlet cont = APILocator.getContentletAPI().findContentletByIdentifier(xmlId.getId(), true, APILocator.getLanguageAPI().getDefaultLanguage().getId(), userAPI.getSystemUser(),false);
            if(cont!=null && InodeUtils.isSet(cont.getInode())){
              xmlSource = new StreamSource(new InputStreamReader(new FileInputStream(cont.getBinary(FileAssetAPI.BINARY_FIELD)), "UTF8"));
            }
          }else{
            File xmlFile = fileAPI.getFileByURI(XMLPath, host, true,userAPI.getSystemUser(),false);
            xmlSource = new StreamSource(new InputStreamReader(new FileInputStream(fileAPI.getAssetIOFile(xmlFile)), "UTF8"));
          }

        }else{
          xmlSource = new StreamSource(XMLPath);
        }

        Source xsltSource = new StreamSource(new InputStreamReader(new FileInputStream(binFile), "UTF8"));

        // create an instance of TransformerFactory
        TransformerFactory transFact = TransformerFactory.newInstance();
        StreamResult result = new StreamResult(new ByteArrayOutputStream());
        Transformer trans = transFact.newTransformer(xsltSource);
View Full Code Here


      if(!canUserEvalute()){
        Logger.error(XsltTool.class, "XSLTTool user does not have scripting access ");
        return null;
      }
      String outputXML = null;
      Source xmlSource = null;
      XSLTranformationDoc doc = null;
      Host host = hostWebAPI.getCurrentHost(request);
     
      /*Get the XSL source*/
      File xslFile = fileAPI.getFileByURI(XSLPath, host, true, userAPI.getSystemUser(), false);
     
      if (doc == null) {
        xmlSource = new StreamSource(new ByteArrayInputStream(xmlString.getBytes("UTF-8")));
       
        Source xsltSource = new StreamSource(new InputStreamReader(new FileInputStream(fileAPI.getAssetIOFile (xslFile)), "UTF8"));
       
        // create an instance of TransformerFactory
        TransformerFactory transFact = TransformerFactory.newInstance();
        StreamResult result = new StreamResult(new ByteArrayOutputStream());
        Transformer trans = transFact.newTransformer(xsltSource);
View Full Code Here

TOP

Related Classes of com.dotcms.repackage.javax.xml.transform.Source

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.