*/
public Vector buildSite(String sBasePath, String sOutputPath, Properties oEnvironmentProps, Properties oUserProps)
throws FileNotFoundException,IOException, DOMException, TransformerException, TransformerConfigurationException {
Transformer oTransformer;
StreamResult oStreamResult;
StreamSource oStreamSrcXML;
InputStream oXMLStream = null;
String sMedia;
Page oCurrentPage;
long lElapsed = 0;
final String sSep = System.getProperty("file.separator");
if (DebugFile.trace) {
lElapsed = System.currentTimeMillis();
DebugFile.writeln("Begin PageSet.buildSite(" + sBasePath + "," + sOutputPath + "...)");
DebugFile.incIdent();
}
oLastXcpt = null;
if (!sBasePath.endsWith(sSep)) sBasePath += sSep;
Vector vPages = pages();
// Move to containers node
if (DebugFile.trace)
DebugFile.writeln("seekChildByName(,[Node], \"containers\")");
Node oContainers = oMSite.seekChildByName(oMSite.getRootNode().getFirstChild(), "containers");
if (oContainers==null) {
if (DebugFile.trace)
DebugFile.writeln("ERROR: <containers> node not found.");
throw new DOMException(DOMException.NOT_FOUND_ERR, "<containers> node not found");
}
// Load XML data stream only once for all containers
if (DebugFile.trace)
DebugFile.writeln("oXMLStream = new FileInputStream(" + sURI + ")");
// For each Page do XSL Transformation
for (int c=0; c<vPages.size(); c++) {
oCurrentPage = (Page) vPages.get(c);
oXMLStream = new FileInputStream(sURI);
oStreamSrcXML = new StreamSource(oXMLStream);
// XSL Transformation
try {
if (DebugFile.trace)
DebugFile.writeln("oTransformer = StylesheetCache.newTransformer(" + sBasePath + "xslt" + sSep + "templates" + sSep + oMSite.name() + sSep + oCurrentPage.template() + ")");
// Get a copy of Stylesheet from cache
oTransformer = StylesheetCache.newTransformer(sBasePath + "xslt" + sSep + "templates" + sSep + oMSite.name() + sSep + oCurrentPage.template());
sMedia = oTransformer.getOutputProperty(OutputKeys.MEDIA_TYPE);
if (null==sMedia)
sMedia = "html";
else
sMedia = sMedia.substring(sMedia.indexOf('/')+1);
if (DebugFile.trace)
DebugFile.writeln("Pages[" + String.valueOf(c) + "].filePath(" + sOutputPath + oCurrentPage.getTitle().replace(' ','_') + "." + sMedia + ")");
oCurrentPage.filePath(sOutputPath + oCurrentPage.getTitle().replace(' ','_') + "." + sMedia);
if (DebugFile.trace)
DebugFile.writeln("oStreamResult = new StreamResult(" + oCurrentPage.filePath() + ")");
oStreamResult = new StreamResult(oCurrentPage.filePath());
// Set environment parameters for stylesheet
StylesheetCache.setParameters(oTransformer, oEnvironmentProps);
// Set user defined parameters for stylesheet