Changeset 35295


Ignore:
Timestamp:
2021-08-16T13:29:24+12:00 (3 years ago)
Author:
kjdon
Message:

if we want to add new namespaces into collection's xsl files, we need to make sure they are added into the main xsl, and then also into expand_gslib xsl, otherwise they will be ignored and left off the page

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3
Files:
3 edited

Legend:

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

    r33726 r35295  
    882882            return XMLTransformer.constructErrorXHTMLPage("Error loading file: "+ expand_gslib_filepath+"\n" + e.getMessage());
    883883        }
    884 
     884               
    885885        // gslib.xsl
    886886        Document gslib_xsl_doc = null;
     
    914914  }
    915915
     916  // if the page xsl or gslib xsl uses namespaces that are not listed in
     917  // expand_gslib, then they will be ignored. So just check through and add
     918  // any in that are missing.
     919  GSXML.addMissingNamespaceAttributes(expand_gslib_xsl_doc.getDocumentElement(), page_xsl.getDocumentElement());
     920  GSXML.addMissingNamespaceAttributes(expand_gslib_xsl_doc.getDocumentElement(), gslib_xsl_doc.getDocumentElement());
    916921
    917922        Document pageAndGslibXsl = null;
     
    944949          XMLTransformer preProcessor = new XMLTransformer();
    945950          preProcessor.transform_withResultNode(expand_gslib_xsl_doc, pageAndGslibXsl, pageAndGslibDoc);
    946 
    947951        }
    948952        if (output.equals("xsl6")) {
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java

    r33712 r35295  
    3535
    3636import org.apache.log4j.Logger;
     37import org.w3c.dom.Attr;
    3738import org.w3c.dom.Document;
    3839import org.w3c.dom.Element;
     
    547548    return true;
    548549  }
     550
     551  /** This adds any namespace attributes from donor_element into main_elem if they are not already there */
     552  public static void addMissingNamespaceAttributes(Element main_elem, Element donor_elem) {
     553    // are there any new namespaces to be added?
     554    NamedNodeMap attributes = donor_elem.getAttributes();
     555    for (int i=0; i<attributes.getLength(); i++) {
     556      Attr att = (Attr)attributes.item(i);
     557      String att_name = att.getName();
     558      if (att_name.startsWith("xmlns:")) {
     559        //logger.error("found a namespace att "+att_name);
     560        if (main_elem.getAttribute(att_name).equals("")) {
     561          main_elem.setAttribute(att_name, att.getValue());
     562          //logger.error("setting att in main");
     563        }
     564      }
     565    }
     566   
     567   
     568  }
    549569    public static Element createMetadataParamList(Document owner, Vector meta_values)
    550570    {
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXSLT.java

    r33669 r35295  
    6262
    6363        Element main = main_xsl.getDocumentElement();
     64                // If extra_xsl has added namespaces, we need to make sure
     65                // they are copied over into main
     66                GSXML.addMissingNamespaceAttributes(main, extra_xsl);
     67               
    6468        Node insertion_point = null;
    6569        Element last_import = GSXML.getLastElementByTagNameNS(main, GSXML.XSL_NAMESPACE, "import");
Note: See TracChangeset for help on using the changeset viewer.