- Timestamp:
- 2013-06-27T16:57:35+12:00 (11 years ago)
- Location:
- main/trunk/greenstone3/src/java/org/greenstone/gsdl3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/Collection.java
r27705 r27716 35 35 import org.greenstone.gsdl3.util.GSFile; 36 36 import org.greenstone.gsdl3.util.GSXML; 37 import org.greenstone.gsdl3.util.GSXSLT; 37 38 import org.greenstone.gsdl3.util.OAIXML; 39 import org.greenstone.gsdl3.util.SimpleMacroResolver; 38 40 import org.greenstone.gsdl3.util.UserContext; 39 41 import org.greenstone.gsdl3.util.XMLTransformer; … … 117 119 118 120 Element coll_config_xml = loadCollConfigFile(); 121 GSXSLT.modifyCollectionConfigForDebug(coll_config_xml); 119 122 Element build_config_xml = loadBuildConfigFile(); 120 123 -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXSLT.java
r26558 r27716 31 31 import org.w3c.dom.Node; 32 32 import org.w3c.dom.NodeList; 33 import org.w3c.dom.UserDataHandler; 33 34 34 35 /** various functions for manipulating Greenstone xslt */ … … 243 244 { 244 245 debugElement.setAttribute("name", currentTemplate.getAttribute("name")); 246 } 247 248 if (currentTemplate.getUserData("xpath") != null) 249 { 250 debugElement.setAttribute("xpath", (String) currentTemplate.getUserData("xpath")); 245 251 } 246 252 … … 604 610 return null; 605 611 } 612 613 public static void modifyCollectionConfigForDebug(Element coll_config_xml) 614 { 615 NodeList xslTemplates = coll_config_xml.getElementsByTagNameNS(GSXML.XSL_NAMESPACE, "template"); 616 NodeList gsfTemplates = coll_config_xml.getElementsByTagNameNS(GSXML.GSF_NAMESPACE, "template"); 617 618 for (int i = 0; i < xslTemplates.getLength() + gsfTemplates.getLength(); i++) 619 { 620 Element currentTemplate = (Element) ((i < xslTemplates.getLength()) ? xslTemplates.item(i) : gsfTemplates.item(i - xslTemplates.getLength())); 621 Element temp = currentTemplate; 622 String xPath = ""; 623 while (!temp.getNodeName().toLowerCase().equals("collectionconfig")) 624 { 625 temp = (Element) temp.getParentNode(); 626 String nodeName = temp.getNodeName(); 627 628 int count = 1; 629 Node counter = temp.getPreviousSibling(); 630 while (counter != null) 631 { 632 if (counter.getNodeType() == Node.ELEMENT_NODE && ((Element) counter).getNodeName().equals(nodeName)) 633 { 634 count++; 635 } 636 counter = counter.getPreviousSibling(); 637 } 638 xPath = nodeName + ((count > 1) ? ("[" + count + "]") : "") + "/" + xPath; 639 } 640 641 xPath = xPath.substring(0, xPath.length() - 1); 642 currentTemplate.setUserData("xpath", xPath, new DataTransferHandler()); 643 } 644 } 645 646 static class DataTransferHandler implements UserDataHandler 647 { 648 public void handle(short operation, String key, Object data, Node src, Node dst) 649 { 650 if (operation == NODE_IMPORTED || operation == NODE_CLONED) 651 { 652 //Thread.dumpStack(); 653 dst.setUserData(key, data, new DataTransferHandler()); 654 } 655 } 656 } 606 657 }
Note:
See TracChangeset
for help on using the changeset viewer.