- Timestamp:
- 2012-04-13T18:51:06+12:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXSLT.java
r25127 r25381 38 38 { 39 39 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 41 57 for (int i = 0; i < children.getLength(); i++) 42 58 { 43 59 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"); 54 64 main.appendChild(main_xsl.importNode(node, true)); 55 65 } 56 66 } 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 57 84 58 85 /**
Note:
See TracChangeset
for help on using the changeset viewer.