Changeset 25381

Show
Ignore:
Timestamp:
13.04.2012 18:51:06 (8 years ago)
Author:
ak19
Message:

Getting the gs2-library servlet (gs2 interface) work again: 1. the changes to GSXSLT.java ensure that when merging inherited stylesheets, not only duplicated template names and but also duplicated template matches as well as include hrefs and output methods are reduced to only one instance, which are solely those occurring in the stylesheet that is most relevant. As stylesheets are passed in from TransformingReceptionist? in the necessary order, this was easily done. 2. To get the main page to work again, the gs2 interface's home.xsl file needed to match a template on page/pageResponse not just pageResponse so that duplicate template matches can be picked up in GSXSLT.java. 3. The gs2 interface's classifier.xsl needs to define a template match for classifierList which has now been copied from the equivalent file in the default interface. This allows the Browse pages of the gs2-library servlet to work again. 4. The namespaces used in default interface's util.xsl has been made consistent with equivalent definitions in other Greenstone xsl files. This did not fix any errors, but it's less confusing now.

Location:
main/trunk/greenstone3
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXSLT.java

    r25127 r25381  
    3838    { 
    3939        Element main = main_xsl.getDocumentElement(); 
    40         NodeList children = extra_xsl.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform", "template"); 
     40        NodeList children = extra_xsl.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform", "include"); 
     41        for (int i = 0; i < children.getLength(); i++) { 
     42                Node node = children.item(i); 
     43            // remove any previous occurrences of xsl:include with the same href value 
     44            removeDuplicateElementsFrom(main, node, "xsl:include", "href"); 
     45            main.appendChild(main_xsl.importNode(node, true)); 
     46        } 
     47        children = extra_xsl.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform", "output"); 
     48        for (int i = 0; i < children.getLength(); i++) { 
     49                Node node = children.item(i); 
     50            // remove any previous occurrences of xsl:output with the same method value 
     51            removeDuplicateElementsFrom(main, node, "xsl:output", "method");             
     52            main.appendChild(main_xsl.importNode(node, true)); 
     53        } 
     54 
     55        children = extra_xsl.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform", "template");         
     56 
    4157        for (int i = 0; i < children.getLength(); i++) 
    4258        { 
    4359            Node node = children.item(i); 
    44             String name = ((Element) node).getAttribute("name"); 
    45             if (!name.equals("")) 
    46             { 
    47                 Element old_template = GSXML.getNamedElement(main, "xsl:template", "name", name); 
    48                 if (old_template != null) 
    49                 { 
    50                     main.removeChild(old_template); 
    51                 } 
    52             } 
    53  
     60            // remove any previous occurrences of xsl:template with the same value for name 
     61            // or even the same value for match (should we use priorities for match?) 
     62            removeDuplicateElementsFrom(main, node, "xsl:template", "name"); 
     63            removeDuplicateElementsFrom(main, node, "xsl:template", "match"); 
    5464            main.appendChild(main_xsl.importNode(node, true)); 
    5565        } 
    5666    } 
     67 
     68    // In element main, tries to find if any previous occurrence of elements with template=templateName,  
     69    // and whose named attribute (attributeName) has the same value as the same attribute in node. 
     70    // If this is the case, such a previous occurrence is removed it from element main 
     71    public static void removeDuplicateElementsFrom(Element main, Node node, String templateName, String attrName) { 
     72    String attr = ((Element) node).getAttribute(attrName); 
     73    if (!attr.equals("")) 
     74        { 
     75        Element old_template = GSXML.getNamedElement(main, templateName, attrName, attr); 
     76        if (old_template != null) 
     77            { 
     78            main.removeChild(old_template); 
     79            } 
     80        } 
     81    } 
     82 
     83 
    5784 
    5885    /** 
  • main/trunk/greenstone3/web/interfaces/default/transform/util.xsl

    r23972 r25381  
    22<xsl:stylesheet version="1.0"  
    33  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
    4   xmlns:gslib="http://www.greenstone.org/XSL/Library" 
     4  xmlns:gslib="http://www.greenstone.org/skinning" 
    55  xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat" 
    6   xmlns:util="http://org.greenstone.gsdl3.util.XSLTUtil" 
     6  xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil" 
    77  exclude-result-prefixes="util gslib gsf"> 
    88   
  • main/trunk/greenstone3/web/interfaces/gs2/transform/classifier.xsl

    r20158 r25381  
    7070    </div> 
    7171  </xsl:template> 
    72    
     72 
     73    <xsl:template match="classifierList"> 
     74    <xsl:param name="collName"/> 
     75    <xsl:param name="serviceName"/> 
     76    <xsl:variable name="selected" select="/page/pageResponse/classifier/@name"/> 
     77    <ul id="classifierlist"> 
     78      <xsl:for-each select="classifier"> 
     79    <xsl:choose> 
     80      <xsl:when test="@name=$selected"> 
     81        <li id="activeclassifier"><xsl:value-of select="displayItem[@name='name']"/></li> 
     82      </xsl:when> 
     83      <xsl:otherwise> 
     84        <li><a href="{$library_name}?a=b&amp;rt=r&amp;s={$serviceName}&amp;c={$collName}&amp;cl={@name}"><xsl:value-of select="displayItem[@name='name']"/></a></li></xsl:otherwise></xsl:choose> 
     85     
     86      </xsl:for-each> 
     87    </ul> 
     88  </xsl:template> 
     89 
    7390 
    7491</xsl:stylesheet> 
  • main/trunk/greenstone3/web/interfaces/gs2/transform/home.xsl

    r20291 r25381  
    4141  <xsl:template name="pageStyle"/> 
    4242 
    43   <xsl:template match="pageResponse"> 
     43  <xsl:template match="page/pageResponse"> 
    4444    <xsl:call-template name="pageBanner"/>  
    4545    <xsl:apply-templates select="collectionList"/>