Changeset 5311
- Timestamp:
- 08/20/10 14:31:13 (18 months ago)
- Location:
- branches/xsltcomp-2010-08-11/pfixcore
- Files:
-
- 10 added
- 9 modified
-
pom.xml (modified) (1 diff)
-
projects/core/xml (added)
-
projects/core/xml/component.xml (added)
-
projects/core/xsl/master.xsl (modified) (3 diffs)
-
projects/core/xsl/metatags.xsl (modified) (1 diff)
-
projects/core/xsl/render.xsl (added)
-
projects/sample1/txt/common.xml (added)
-
projects/sample1/txt/pages/main_home.xml (modified) (1 diff)
-
src/de/schlund/pfixcore/util/TransformerCallback.java (modified) (1 diff)
-
src/de/schlund/pfixcore/workflow/Navigation.java (modified) (1 diff)
-
src/de/schlund/pfixxml/RenderContext.java (added)
-
src/de/schlund/pfixxml/RenderContextSaxon1.java (added)
-
src/de/schlund/pfixxml/RenderContextSaxon2.java (added)
-
src/de/schlund/pfixxml/RenderExtension.java (added)
-
src/de/schlund/pfixxml/RenderExtensionSaxon1.java (added)
-
src/de/schlund/pfixxml/targets/TargetGenerator.java (modified) (10 diffs)
-
src/de/schlund/pfixxml/util/Xslt.java (modified) (1 diff)
-
src/org/pustefixframework/http/AbstractPustefixXMLRequestHandler.java (modified) (4 diffs)
-
startup.properties (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/xsltcomp-2010-08-11/pfixcore/pom.xml
r5303 r5311 5 5 <artifactId>pfixcore</artifactId> 6 6 <name>pfixcore</name> 7 <version>0.13.22- SNAPSHOT</version>7 <version>0.13.22-xsltcomp-SNAPSHOT</version> 8 8 <dependencies> 9 9 <dependency> -
branches/xsltcomp-2010-08-11/pfixcore/projects/core/xsl/master.xsl
r5261 r5311 104 104 <ixsl:import href="core/xsl/include.xsl"/> 105 105 <ixsl:import href="core/xsl/functions.xsl"/> 106 <ixsl:import href="core/xsl/render.xsl"/> 106 107 107 108 <!-- generate user defined imports --> … … 128 129 <ixsl:param name="navitree" select="$__navitree"/> 129 130 130 <!-- The next threeparameters are opaque Java objects. Use them only to pass them to extension functions! -->131 <!-- The next four parameters are opaque Java objects. Use them only to pass them to extension functions! --> 131 132 <ixsl:param name="__context__"/> 132 133 <ixsl:param name="__spdoc__"/> … … 260 261 261 262 <ixsl:template match="/"> 263 <ixsl:call-template name="__render_start__"/> 262 264 <xsl:choose> 263 265 <!-- <xsl:when test="//frameset"> --> -
branches/xsltcomp-2010-08-11/pfixcore/projects/core/xsl/metatags.xsl
r3872 r5311 9 9 <xsl:import href="core/xsl/include.xsl"/> 10 10 <xsl:import href="core/xsl/utils.xsl"/> 11 <xsl:import href="core/xsl/render.xsl"/> 11 12 12 13 <cus:custom_xsl/> -
branches/xsltcomp-2010-08-11/pfixcore/projects/sample1/txt/pages/main_home.xml
r3873 r5311 97 97 </table> 98 98 </pfx:forminput> 99 99 100 <pfx:render href="sample1/txt/common.xml" part="content"/> 101 100 102 </center> 101 103 </theme> -
branches/xsltcomp-2010-08-11/pfixcore/src/de/schlund/pfixcore/util/TransformerCallback.java
r4854 r5311 388 388 } 389 389 390 public static String getHandlerPath(String targetgen, String page) { 391 TargetGenerator gen = TargetGeneratorFactory.getInstance().getGenerator(targetgen); 392 return gen.getNavigation().getHandler(page); 393 } 394 390 395 } -
branches/xsltcomp-2010-08-11/pfixcore/src/de/schlund/pfixcore/workflow/Navigation.java
r3367 r5311 154 154 } 155 155 156 public String getHandler(String page) { 157 NavigationElement element = pagetonavi.get(page); 158 if(element == null) throw new IllegalArgumentException("Page '" + page + "' not found in navigation."); 159 return element.getHandler(); 160 } 161 162 156 163 public class NavigationElement { 157 164 private ArrayList<NavigationElement> children = new ArrayList<NavigationElement>(); -
branches/xsltcomp-2010-08-11/pfixcore/src/de/schlund/pfixxml/targets/TargetGenerator.java
r4017 r5311 55 55 56 56 import de.schlund.pfixcore.util.Meminfo; 57 import de.schlund.pfixcore.workflow.Navigation; 57 58 import de.schlund.pfixcore.workflow.NavigationFactory; 59 import de.schlund.pfixcore.workflow.NavigationInitializationException; 58 60 import de.schlund.pfixxml.IncludeDocumentFactory; 59 61 import de.schlund.pfixxml.XMLException; … … 72 74 import de.schlund.pfixxml.targets.cachestat.SPCacheStatistic; 73 75 import de.schlund.pfixxml.util.TransformerHandlerAdapter; 76 import de.schlund.pfixxml.util.XMLUtils; 74 77 import de.schlund.pfixxml.util.Xml; 75 78 import de.schlund.pfixxml.util.XsltVersion; … … 121 124 122 125 private FileResource config_path; 123 126 127 private Navigation navigation; 128 124 129 //-- 125 130 … … 162 167 } 163 168 169 public Navigation getNavigation() { 170 return navigation; 171 } 172 164 173 //-- targets 165 174 … … 172 181 public Target getTarget(String key) { 173 182 synchronized (alltargets) { 174 return (Target) alltargets.get(key); 183 Target target = (Target) alltargets.get(key); 184 if(target == null && key.contains("$")) { 185 Target compTarget = createTargetForComponent(key); 186 return compTarget; 187 } 188 return target; 175 189 } 176 190 } … … 322 336 throw new RuntimeException("Could not get instance of SAXTransformerFactory!"); 323 337 } 324 338 try { 339 XMLUtils.serialize(config); 340 } catch(Exception x) { 341 x.printStackTrace(); 342 } 325 343 Element root = (Element) config.getElementsByTagName("make").item(0); 326 344 … … 448 466 allstructs.put(nameattr, struct); 449 467 } 468 469 470 try { 471 navigation = NavigationFactory.getInstance().getNavigation(this.config_path,getXsltVersion()); 472 } catch (NavigationInitializationException e) { 473 throw new XMLException("Error reading page navigation."); 474 } 475 450 476 LOG.warn("\n=====> Preliminaries took " + (System.currentTimeMillis() - start) + "ms. Now looping over " + allstructs.keySet().size() + " targets"); 451 477 start = System.currentTimeMillis(); … … 534 560 virtual.addParam(XSLPARAM_TG, tgParam); 535 561 virtual.addParam(XSLPARAM_TKEY, key); 562 System.out.println(">>>>>>>>>>>>>>>>>> "+tgParam+" "+key); 536 563 try { 537 virtual.addParam(XSLPARAM_NAVITREE, NavigationFactory.getInstance().getNavigation(this.config_path,getXsltVersion()).getNavigationXMLElement());564 virtual.addParam(XSLPARAM_NAVITREE, navigation.getNavigationXMLElement()); 538 565 } catch (Exception e) { 539 566 throw new XMLException("Cannot get navigation tree", e); … … 555 582 } 556 583 } 557 584 585 private TargetRW createTargetForComponent(String componentKey) { 586 587 String[] comps = splitComponentKey(componentKey); 588 String href = comps[0]; 589 String part = comps[1]; 590 String module = ""; 591 if(comps.length>2) module = comps[2]; 592 String search = ""; 593 if(comps.length>3) search = comps[3]; 594 595 System.out.println("NNNNNNNNNNNNNNNNNN: " + componentKey); 596 //sample1_txt_pages_main_foo@content::foo:bar:baz.xml 597 Themes themes = global_themes; 598 599 if(getTargetRW(name) != null) throw new RuntimeException("Target already exists"); 600 601 String tgParam = config_path.toString(); 602 603 XMLVirtualTarget xmlTarget = (XMLVirtualTarget)createTarget(TargetType.XML_VIRTUAL, componentKey + ".xml", themes); 604 Target xmlSource = createTarget(TargetType.XML_LEAF, "core/xml/component.xml", null); 605 Target xslSource = createTarget(TargetType.XSL_VIRTUAL, "metatags.xsl", null); 606 xmlTarget.setXMLSource(xmlSource); 607 xmlTarget.setXSLSource(xslSource); 608 xmlTarget.addParam(XSLPARAM_TG, tgParam); 609 xmlTarget.addParam(XSLPARAM_TKEY, componentKey + ".xml"); 610 xmlTarget.addParam("component_href", href); 611 xmlTarget.addParam("component_part", part); 612 xmlTarget.addParam("component_module", module); 613 xmlTarget.addParam("component_search", search); 614 615 XSLVirtualTarget xslTarget = (XSLVirtualTarget)createTarget(TargetType.XSL_VIRTUAL, componentKey + ".xsl", themes); 616 xmlSource = xmlTarget; 617 xslSource = createTarget(TargetType.XSL_VIRTUAL, "master.xsl", null); 618 xslTarget.setXMLSource(xmlSource); 619 xslTarget.setXSLSource(xslSource); 620 xslTarget.addParam(XSLPARAM_TG, tgParam); 621 xslTarget.addParam(XSLPARAM_TKEY, componentKey + ".xsl"); 622 623 return xslTarget; 624 } 625 626 627 628 629 558 630 // ******************************************************************************************* 559 631 private TargetRW getTargetRW(String key) { … … 879 951 return this.config_path; 880 952 } 953 954 public static String createComponentKey(String href, String part, String module, String search) { 955 if(href == null || href.equals("")) throw new IllegalArgumentException("Argument 'href' must not be empty"); 956 if(part == null || part.equals("")) throw new IllegalArgumentException("Argument 'part' must not be empty"); 957 if(module == null) module = ""; 958 if(search == null) search = ""; 959 String targetKey = encode(href) + "$" + encode(part) + "$" + encode(module) + "$" + encode(search); 960 return targetKey; 961 } 962 963 public static String encode(String str) { 964 str = str.replace("%", "%" + Integer.toHexString('%')); 965 str = str.replace("$", "%" + Integer.toHexString('$')); 966 str = str.replace("+", "%" + Integer.toHexString('+')); 967 str = str.replace("/", "+"); 968 return str; 969 } 970 971 public static String decode(String str) { 972 str = str.replace("+", "/"); 973 str = str.replace("%" + Integer.toHexString('+'), "+"); 974 str = str.replace("%" + Integer.toHexString('$'), "$"); 975 str = str.replace("%" + Integer.toHexString('%'), "%"); 976 return str; 977 } 978 979 public static String[] splitComponentKey(String componentKey) { 980 String[] comps = componentKey.split("\\$"); 981 for(int i=0; i<comps.length; i++) { 982 comps[i] = decode(comps[i]); 983 } 984 return comps; 985 } 881 986 882 987 } -
branches/xsltcomp-2010-08-11/pfixcore/src/de/schlund/pfixxml/util/Xslt.java
r4672 r5311 268 268 if(href.equals("core/xsl/include.xsl")) { 269 269 if(xsltVersion==XsltVersion.XSLT2) href="core/xsl/include_xslt2.xsl"; 270 } else if(href.equals("core/xsl/render.xsl")) { 271 if(xsltVersion==XsltVersion.XSLT2) href="core/xsl/render_xslt2.xsl"; 270 272 } 271 273 -
branches/xsltcomp-2010-08-11/pfixcore/src/org/pustefixframework/http/AbstractPustefixXMLRequestHandler.java
r4661 r5311 28 28 import java.security.MessageDigest; 29 29 import java.security.NoSuchAlgorithmException; 30 import java.util.Collections; 30 31 import java.util.Enumeration; 31 32 import java.util.HashMap; … … 59 60 import de.schlund.pfixcore.workflow.NavigationInitializationException; 60 61 import de.schlund.pfixxml.PfixServletRequest; 62 import de.schlund.pfixxml.RenderContext; 61 63 import de.schlund.pfixxml.RenderingException; 62 64 import de.schlund.pfixxml.RequestParam; … … 729 731 ((spdoc != null) ? ("pagename=" + spdoc.getPagename()) : "spdoc==null")); 730 732 } 733 RenderContext renderContext = RenderContext.create(generator.getXsltVersion()); 734 paramhash.put("__rendercontext__", renderContext); 735 renderContext.setParameters(Collections.unmodifiableMap(paramhash)); 731 736 try { 737 long t1 = System.currentTimeMillis(); 732 738 Xslt.transform(spdoc.getDocument(), stylevalue, paramhash, new StreamResult(output), getServletEncoding()); 739 long t2 = System.currentTimeMillis(); 740 System.out.println("TTTTTTTTTTTTTTTTTTTT: " + (t2-t1)); 733 741 } catch (TransformerException e) { 734 742 Throwable inner = e.getException(); … … 744 752 throw e; 745 753 } 746 } 754 } 747 755 } 748 756
