Changeset 25644


Ignore:
Timestamp:
2012-05-23T16:40:22+12:00 (12 years ago)
Author:
sjm84
Message:

Adding in some unfinished code that will help us view the XML a page was generated with

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java

    r25635 r25644  
    6161    protected TransformerFactory transformerFactory = null;
    6262    protected DOMParser parser = null;
     63
     64    boolean _debug = false;
    6365
    6466    public TransformingReceptionist()
     
    436438            Text intnametext = theXML.createTextNode((String) config_params.get(GSConstants.INTERFACE_NAME));
    437439            intname.appendChild(intnametext);
    438            
     440
    439441            Element siteName = theXML.createElement("param");
    440442            siteName.setAttribute("name", "site_name");
     
    501503            String configStylesheet_file = GSFile.stylesheetFile(GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME), collection, (String) this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces, "config_format.xsl");
    502504            Document configStylesheet_doc = this.converter.getDOM(new File(configStylesheet_file));
     505
     506            if (_debug)
     507            {
     508                GSXSLT.modifyConfigFormatForDebug(configStylesheet_doc, GSFile.collectionConfigFile(GSFile.collectDir(GSFile.siteHome(GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME)) + File.separator + collection)));
     509            }
    503510
    504511            if (configStylesheet_doc != null)
     
    527534
    528535                // add extracted GSF statements in to the main stylesheet
    529                 GSXSLT.mergeStylesheets(style_doc, new_format);
     536                if (_debug)
     537                {
     538                    GSXSLT.mergeStylesheetsDebug(style_doc, new_format, true, true, "OTHER1", GSFile.collectionConfigFile(GSFile.collectDir(GSFile.siteHome(GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME)) + File.separator + collection)));
     539                }
     540                else
     541                {
     542                    GSXSLT.mergeStylesheets(style_doc, new_format, true);
     543                }
    530544                //System.out.println("added extracted GSF statements into the main stylesheet") ;
    531545
     
    536550            {
    537551                logger.error(" couldn't parse the config_format stylesheet, adding the format info as is");
    538                 GSXSLT.mergeStylesheets(style_doc, format_elem);
     552                GSXSLT.mergeStylesheets(style_doc, format_elem, true);
    539553                //GSXSLT.mergeStylesheets(oldStyle_doc, format_elem);
    540554            }
     
    594608        Document skinAndLibraryXsl = null;
    595609        Document skinAndLibraryDoc = converter.newDOM();
    596        
     610
    597611        // Applying the preprocessing XSLT - in its own block {} to allow use of non-unique variable names
    598612        {
     
    626640            //System.out.println("GS-Lib statements are now expanded") ;
    627641        }
    628    
    629642
    630643        //The following code is to be uncommented if we need to append the extracted GSF statements
     
    763776            try
    764777            {
    765                 Document inlineTemplateDoc = this.converter.getDOM("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:java=\"http://xml.apache.org/xslt/java\" xmlns:util=\"xalan://org.greenstone.gsdl3.util.XSLTUtil\" xmlns:gsf=\"http://www.greenstone.org/greenstone3/schema/ConfigFormat\">" + inlineTemplate + "</xsl:stylesheet>");
    766                 GSXSLT.mergeStylesheets(skinAndLibraryDoc, inlineTemplateDoc.getDocumentElement());
     778                Document inlineTemplateDoc = this.converter.getDOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:java=\"http://xml.apache.org/xslt/java\" xmlns:util=\"xalan://org.greenstone.gsdl3.util.XSLTUtil\" xmlns:gsf=\"http://www.greenstone.org/greenstone3/schema/ConfigFormat\">" + inlineTemplate + "</xsl:stylesheet>", "UTF-8");
     779
     780                if (_debug)
     781                {
     782                    GSXSLT.mergeStylesheetsDebug(skinAndLibraryDoc, inlineTemplateDoc.getDocumentElement(), true, true, "OTHER2", "INLINE");
     783                }
     784                else
     785                {
     786                    GSXSLT.mergeStylesheets(skinAndLibraryDoc, inlineTemplateDoc.getDocumentElement(), true);
     787                }
    767788            }
    768789            catch (Exception ex)
     
    780801        {
    781802            return doc;
     803        }
     804
     805        if(_debug)
     806        {
     807            GSXML.addDebugSpanTags(skinAndLibraryDoc);
    782808        }
    783809
     
    834860        if (configStylesheet_doc != null)
    835861        {
    836             Document format_doc = this.converter.newDOM();
     862            Document format_doc = XMLConverter.newDOM();
    837863            format_doc.appendChild(format_doc.importNode(skinAndLibraryDoc.getDocumentElement().cloneNode(true), true));
    838864            Node result = this.transformer.transform(configStylesheet_doc, format_doc, config_params);
    839             GSXSLT.mergeStylesheets(skinAndLibraryDoc, ((Document) result).getDocumentElement());
     865
     866            if (_debug)
     867            {
     868                GSXSLT.mergeStylesheetsDebug(skinAndLibraryDoc, ((Document) result).getDocumentElement(), true, true, "OTHER3", GSFile.collectionConfigFile(GSFile.collectDir(GSFile.siteHome(GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME)) + File.separator + collection)));
     869            }
     870            else
     871            {
     872                GSXSLT.mergeStylesheets(skinAndLibraryDoc, ((Document) result).getDocumentElement(), true);
     873            }
    840874        }
    841875    }
     
    915949            }
    916950
    917             GSXSLT.mergeStylesheets(finalDoc, currentDoc.getDocumentElement());
     951            if (_debug)
     952            {
     953                GSXSLT.mergeStylesheetsDebug(finalDoc, currentDoc.getDocumentElement(), true, true, stylesheets.get(stylesheets.size() - 1).getAbsolutePath(), stylesheets.get(i).getAbsolutePath());
     954            }
     955            else
     956            {
     957                GSXSLT.mergeStylesheets(finalDoc, currentDoc.getDocumentElement(), true);
     958            }
     959        }
     960
     961        if (_debug)
     962        {
     963            GSXSLT.inlineImportAndIncludeFiles(finalDoc, null, 0);
    918964        }
    919965
Note: See TracChangeset for help on using the changeset viewer.