2907N/A/*
2907N/A * CDDL HEADER START
2907N/A *
2907N/A * The contents of this file are subject to the terms of the
2907N/A * Common Development and Distribution License, Version 1.0 only
2907N/A * (the "License"). You may not use this file except in compliance
2907N/A * with the License.
2907N/A *
2907N/A * You can obtain a copy of the license at
2907N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE
2907N/A * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
2907N/A * See the License for the specific language governing permissions
2907N/A * and limitations under the License.
2907N/A *
2907N/A * When distributing Covered Code, include this CDDL HEADER in each
2907N/A * file and include the License file at
2907N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
2907N/A * add the following below this CDDL HEADER, with the fields enclosed
2907N/A * by brackets "[]" replaced with your own identifying information:
2907N/A * Portions Copyright [yyyy] [name of copyright owner]
2907N/A *
2907N/A * CDDL HEADER END
2907N/A *
2907N/A *
5061N/A * Copyright 2008-2010 Sun Microsystems, Inc.
2907N/A */
2907N/Aimport java.io.*;
2907N/Aimport java.lang.*;
2907N/Aimport java.util.ArrayList;
2907N/Aimport javax.xml.transform.*;
2907N/Aimport java.net.*;
2907N/A
2907N/Apublic class WriteHTMLFile
2907N/A{
2907N/A private String group;
2907N/A private ArrayData arrayData;
2907N/A private ArrayList <String> strIndividualSteps;
2907N/A
2907N/A public WriteHTMLFile(String inGroup)
2907N/A {
2907N/A group = inGroup;
2907N/A strIndividualSteps = null;
2907N/A }
2907N/A
2907N/A public void MakeHTMLFile(ArrayData arrayData, String strDir, String strParentDir) throws IOException
2907N/A {
2907N/A String strDirName = strDir + "/" + group;
2907N/A File fileDirName = new File(strDirName);
2907N/A if(!fileDirName.isDirectory())
2907N/A {
2907N/A if(!fileDirName.mkdirs())
2907N/A {
2907N/A System.out.println("Could not create directory, " + strDirName);
2907N/A System.out.println("Exiting.....");
2907N/A System.exit(0);
2907N/A }
2907N/A }
2907N/A
2907N/A String xmlFilename;
2907N/A String htmlFilename;
5061N/A File xslFilename = new File(strParentDir + "/../../shared/xsl/testspec-stylesheet.xsl");
2907N/A
2907N/A if(group.indexOf("/") < 0)
2907N/A {
2907N/A xmlFilename = strDirName + "/" + group + ".xml";
2907N/A htmlFilename = strDirName + "/" + group + ".html";
2907N/A }
2907N/A else
2907N/A {
2907N/A String tmpStr = new String(group);
2907N/A int index = tmpStr.indexOf("/") + 1;
2907N/A String subStr = tmpStr.substring(index);
2907N/A xmlFilename = strDirName + "/" + subStr + ".xml";
2907N/A htmlFilename = strDirName + "/" + subStr + ".html";
2907N/A }
2907N/A
2907N/A System.out.println("Processing: " + xmlFilename);
2907N/A
2907N/A try{
2907N/A TransformerFactory transFactory = TransformerFactory.newInstance();
2907N/A
2907N/A Transformer transformer = transFactory.newTransformer
2907N/A (new javax.xml.transform.stream.StreamSource(xslFilename));
2907N/A
2907N/A transformer.transform
2907N/A (new javax.xml.transform.stream.StreamSource(xmlFilename),
2907N/A new javax.xml.transform.stream.StreamResult
2907N/A (new FileOutputStream(htmlFilename))
2907N/A );
2907N/A }
2907N/A
2907N/A catch (Exception e) {
2907N/A e.printStackTrace( );
2907N/A }
2907N/A
2907N/A }
2907N/A
2907N/A}