Changeset 6114 for trunk

Show
Ignore:
Timestamp:
01/20/12 18:18:07 (4 months ago)
Author:
mtld
Message:

added include existence check support

Location:
trunk/pustefix-core/src/main
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/pustefix-core/src/main/java/de/schlund/pfixxml/IncludeDocumentExtension.java

    r5965 r6114  
    3838import de.schlund.pfixxml.resources.DynamicResourceProvider; 
    3939import de.schlund.pfixxml.resources.Resource; 
     40import de.schlund.pfixxml.resources.ResourceProviderRegistry; 
    4041import de.schlund.pfixxml.resources.ResourceUtil; 
    4142import de.schlund.pfixxml.targets.TargetGenerator; 
     
    7071    private static Pattern dynamicUriPattern = Pattern.compile("dynamic://[^?#]*(\\?([^#]*))?(#.*)?"); 
    7172     
    72     private static DynamicResourceProvider dynamicResourceProvider = new DynamicResourceProvider(); 
     73    private static DynamicResourceProvider dynamicResourceProvider = (DynamicResourceProvider)ResourceProviderRegistry.getResourceProvider("dynamic"); 
    7374     
    7475    //~ Methods 
     
    121122        } 
    122123         
    123         String uriStr = path_str; 
    124          
    125         if(!uriStr.matches("^\\w+:.*")) { 
    126             boolean dynamic = false; 
    127             if(search!=null && !search.trim().equals("")) { 
    128                 if(search.equals("dynamic")) dynamic = true; 
    129                 else throw new XMLException("Unsupported include search argument: " + search); 
    130             } 
    131             if(dynamic) { 
    132                 String filter = FilterHelper.getFilter(tenant, language); 
    133                 uriStr = "dynamic:/" + path_str + "?part=" + part + "&parent=" + parent_uri_str; 
    134                 if(!"WEBAPP".equalsIgnoreCase(module)) { 
    135                     if(module != null) { 
    136                         uriStr += "&module="+module; 
    137                     } else if("module".equals(parentURI.getScheme())) { 
    138                         uriStr += "&module="+parentURI.getAuthority(); 
    139                     } 
    140                     if(filter != null)  uriStr += "&filter=" + URLEncoder.encode(filter, "UTF-8"); 
    141                 } 
    142             } else { 
    143                 if(!"WEBAPP".equalsIgnoreCase(module)) { 
    144                     if(module != null) { 
    145                         uriStr = "module://" + module + "/" + path_str; 
    146                     } else if("module".equals(parentURI.getScheme())) { 
    147                         uriStr = "module://" + parentURI.getAuthority() + "/" + path_str; 
    148                     } 
    149                 } 
    150             } 
    151         } else if(uriStr.matches("^dynamic://.*")) { 
    152             //add missing dynamic URI parameters 
    153             Matcher matcher = dynamicUriPattern.matcher(uriStr); 
    154             if(matcher.matches()) { 
    155                 URIParameters params; 
    156                 if(matcher.group(2) != null) params = new URIParameters(matcher.group(2), "UTF-8"); 
    157                 else params = new URIParameters(); 
    158                 if(params.getParameter("part") == null) params.addParameter("part", part); 
    159                 if(params.getParameter("parent") == null) params.addParameter("parent", parent_uri_str); 
    160                 if(matcher.group(2) == null) { 
    161                     if(matcher.group(3) == null) uriStr += "?" + params.toString(); 
    162                     else uriStr = uriStr.substring(0, matcher.start(3)) + "?" +  params.toString() + uriStr.substring(matcher.start(3)); 
    163                 } else { 
    164                     uriStr = uriStr.substring(0, matcher.start(2)) + params.toString() + uriStr.substring(matcher.end(2)); 
    165                 } 
    166             } 
    167         } 
    168  
     124        String uriStr = makeURI(path_str, part, module, search, tenant, language, parentURI); 
     125         
    169126        // EEEEK! this code is in need of some serious beautifying.... 
    170127         
     
    326283    } 
    327284     
     285    private static String makeURI(String path, String part, String module, String search, String tenant, String language, URI parentURI) throws Exception { 
     286        String uriStr = path; 
     287        if(!uriStr.matches("^\\w+:.*")) { 
     288            boolean dynamic = false; 
     289            if(search!=null && !search.trim().equals("")) { 
     290                if(search.equals("dynamic")) dynamic = true; 
     291                else throw new XMLException("Unsupported include search argument: " + search); 
     292            } 
     293            if(dynamic) { 
     294                String filter = FilterHelper.getFilter(tenant, language); 
     295                uriStr = "dynamic:/" + path + "?part=" + part + "&parent=" + parentURI.toASCIIString(); 
     296                if(!"WEBAPP".equalsIgnoreCase(module)) { 
     297                    if(module != null) { 
     298                        uriStr += "&module="+module; 
     299                    } else if("module".equals(parentURI.getScheme())) { 
     300                        uriStr += "&module="+parentURI.getAuthority(); 
     301                    } 
     302                    if(filter != null)  uriStr += "&filter=" + URLEncoder.encode(filter, "UTF-8"); 
     303                } 
     304            } else { 
     305                if(!"WEBAPP".equalsIgnoreCase(module)) { 
     306                    if(module != null) { 
     307                        uriStr = "module://" + module + "/" + path; 
     308                    } else if("module".equals(parentURI.getScheme())) { 
     309                        uriStr = "module://" + parentURI.getAuthority() + "/" + path; 
     310                    } 
     311                } 
     312            } 
     313        } else if(uriStr.matches("^dynamic://.*")) { 
     314            //add missing dynamic URI parameters 
     315            Matcher matcher = dynamicUriPattern.matcher(uriStr); 
     316            if(matcher.matches()) { 
     317                URIParameters params; 
     318                if(matcher.group(2) != null) params = new URIParameters(matcher.group(2), "UTF-8"); 
     319                else params = new URIParameters(); 
     320                if(params.getParameter("part") == null) params.addParameter("part", part); 
     321                if(params.getParameter("parent") == null) params.addParameter("parent", parentURI.toASCIIString()); 
     322                if(matcher.group(2) == null) { 
     323                    if(matcher.group(3) == null) uriStr += "?" + params.toString(); 
     324                    else uriStr = uriStr.substring(0, matcher.start(3)) + "?" +  params.toString() + uriStr.substring(matcher.start(3)); 
     325                } else { 
     326                    uriStr = uriStr.substring(0, matcher.start(2)) + params.toString() + uriStr.substring(matcher.end(2)); 
     327                } 
     328            } 
     329        } 
     330        return uriStr; 
     331    } 
     332     
     333    public static final boolean exists(XsltContext context, String path_str, String part, TargetGenerator targetgen,  
     334                                       String targetkey, String module, String search, String tenant, String language) throws Exception { 
     335 
     336        if(path_str.startsWith("docroot:")) path_str = path_str.substring(9); 
     337        if(module != null) { 
     338            module = module.trim(); 
     339            if(module.equals("")) module = null; 
     340        } 
     341        if (path_str == null || path_str.equals("")) { 
     342            throw new XMLException("Need href for pfx:include existence check"); 
     343        } 
     344        if (path_str.startsWith("/")) path_str = path_str.substring(1); 
     345         
     346        String parentSystemId = getSystemId(context); 
     347        URI parentURI = new URI(parentSystemId); 
     348        String uriStr = makeURI(path_str, part, module, search, tenant, language, parentURI); 
     349         
     350        try { 
     351             
     352            Resource    path        = ResourceUtil.getResource(uriStr); 
     353            resolvedUri.set(path.toURI().toString()); 
     354           
     355            VirtualTarget target = (VirtualTarget) targetgen.getTarget(targetkey); 
     356 
     357            String[] themes = targetgen.getGlobalThemes().getThemesArr(); 
     358            if (!targetkey.equals(NOTARGET)) { 
     359                themes = target.getThemes().getThemesArr(); 
     360            } 
     361            if (themes == null) { 
     362                XMLException ex = new XMLException("Target has a 'null' themes array!"); 
     363                target.setStoredException(ex); 
     364                throw ex; 
     365            } 
     366            if (themes.length < 1) { 
     367                XMLException ex = new XMLException("Target has an empty themes array!"); 
     368                target.setStoredException(ex); 
     369                throw ex; 
     370            } 
     371             
     372            if (path != null && path.exists()) { 
     373                IncludePartsInfo partsInfo = dynamicResourceProvider.getIncludePartsInfoFactory().getIncludePartsInfo(path); 
     374                if(partsInfo != null) { 
     375                    IncludePartInfo partInfo = partsInfo.getPart(part); 
     376                    if(partInfo != null) { 
     377                        String matchingTheme = partInfo.getMatchingTheme(themes); 
     378                        if(matchingTheme != null) { 
     379                            return true; 
     380                        } 
     381                    } 
     382                } 
     383            } 
     384            return false; 
     385             
     386        } catch (Exception e) { 
     387            ExtensionFunctionUtils.setExtensionFunctionError(e); 
     388            throw e; 
     389        } 
     390    }  
     391     
     392     
    328393    public static String getResolvedURI() { 
    329394        return resolvedUri.get(); 
     
    375440        } 
    376441    } 
     442     
     443    public static final String getModuleFromSystemId(XsltContext context) { 
     444        String sysid = context.getSystemId(); 
     445        if(sysid.startsWith("module://")) { 
     446            int ind = sysid.indexOf('/', 9); 
     447            String module = sysid.substring(9, ind); 
     448            return module; 
     449        } 
     450        return ""; 
     451    } 
    377452 
    378453    public static boolean isIncludeDocument(XsltContext context) { 
    379454        return context.getDocumentElementName().equals("include_parts"); 
    380455    } 
     456 
    381457}// end of class IncludeDocumentExtension 
  • trunk/pustefix-core/src/main/java/de/schlund/pfixxml/IncludeDocumentExtensionSaxon1.java

    r5841 r6114  
    4444    } 
    4545     
     46    public static boolean exists(Context context,String path_str,String part,TargetGenerator targetgen,String targetkey, 
     47            String module,String search, String tenant, String language) throws Exception {     
     48        try { 
     49            XsltContext xsltContext=new XsltContextSaxon1(context); 
     50            return IncludeDocumentExtension.exists(xsltContext,path_str,part,targetgen,targetkey, 
     51                                                   module,search, tenant, language); 
     52        } catch(Exception x) { 
     53            ExtensionFunctionUtils.setExtensionFunctionError(x); 
     54            throw x; 
     55        } 
     56    } 
     57     
    4658    public static String getSystemId(Context context) { 
    4759        XsltContext xsltContext=new XsltContextSaxon1(context); 
     
    5264        XsltContext xsltContext=new XsltContextSaxon1(context); 
    5365        return IncludeDocumentExtension.getRelativePathFromSystemId(xsltContext); 
     66    } 
     67     
     68    public static final String getModuleFromSystemId(Context context) { 
     69        XsltContext xsltContext = new XsltContextSaxon1(context); 
     70        return IncludeDocumentExtension.getModuleFromSystemId(xsltContext); 
    5471    } 
    5572     
  • trunk/pustefix-core/src/main/java/de/schlund/pfixxml/IncludeDocumentExtensionSaxon2.java

    r5841 r6114  
    4646    } 
    4747     
     48    public static boolean exists(XPathContext context,String path_str,String part,TargetGenerator targetgen,String targetkey, 
     49            String module,String search, String tenant, String language) throws Exception {     
     50        try { 
     51            XsltContext xsltContext=new XsltContextSaxon2(context); 
     52            return IncludeDocumentExtension.exists(xsltContext,path_str,part,targetgen,targetkey, 
     53                                                   module,search, tenant, language); 
     54        } catch(Exception x) { 
     55            ExtensionFunctionUtils.setExtensionFunctionError(x); 
     56            throw x; 
     57        } 
     58    } 
     59     
    4860    public static String getSystemId(XPathContext context) { 
    4961        XsltContext xsltContext=new XsltContextSaxon2(context); 
     
    5466        XsltContext xsltContext=new XsltContextSaxon2(context); 
    5567        return IncludeDocumentExtension.getRelativePathFromSystemId(xsltContext); 
     68    } 
     69     
     70    public static final String getModuleFromSystemId(XPathContext context) { 
     71        XsltContext xsltContext = new XsltContextSaxon2(context); 
     72        return IncludeDocumentExtension.getModuleFromSystemId(xsltContext); 
    5673    } 
    5774     
  • trunk/pustefix-core/src/main/java/de/schlund/pfixxml/IncludePartInfo.java

    r5788 r6114  
    11package de.schlund.pfixxml; 
    22 
     3import java.util.HashSet; 
    34import java.util.Set; 
    45 
    56public class IncludePartInfo { 
    67 
    7     private String name; 
    8     private boolean render; 
    9     private Set<String> renderVariants; 
     8    private final String name; 
     9    private final boolean render; 
     10    private final Set<String> renderVariants; 
     11    private final Set<String> themes; 
    1012     
    1113    public IncludePartInfo(String name, boolean render, Set<String> renderVariants) { 
     
    1315        this.render = render; 
    1416        this.renderVariants = renderVariants; 
     17        this.themes = new HashSet<String>(); 
    1518    } 
    1619     
     
    2730    } 
    2831     
     32    public Set<String> getThemes() { 
     33        return themes; 
     34    } 
     35     
     36    void addTheme(String theme) { 
     37        themes.add(theme); 
     38    } 
     39     
     40    public String getMatchingTheme(String[] themeList) { 
     41        for(String theme: themeList) { 
     42            if(themes.contains(theme)) { 
     43                return theme; 
     44            } 
     45        } 
     46        return null; 
     47    } 
     48 
    2949} 
  • trunk/pustefix-core/src/main/java/de/schlund/pfixxml/IncludePartsInfo.java

    r5788 r6114  
    11package de.schlund.pfixxml; 
    22 
     3import java.util.Collections; 
    34import java.util.Map; 
    45 
    56public class IncludePartsInfo { 
    67     
    7     private Map<String, IncludePartInfo> parts; 
     8    private final Map<String, IncludePartInfo> parts; 
    89    private long lastMod; 
    910     
    10     public void setParts(Map<String, IncludePartInfo> parts) { 
    11         this.parts = parts; 
     11    public IncludePartsInfo(Map<String, IncludePartInfo> parts) { 
     12        this.parts = Collections.unmodifiableMap(parts); 
    1213    } 
    1314     
     
    1617    } 
    1718     
    18     public void setLastMod(long lastMod) { 
    19         this.lastMod = lastMod; 
     19    public IncludePartInfo getPart(String partName) { 
     20        return parts.get(partName); 
    2021    } 
    2122     
     
    2425    } 
    2526     
     27    void setLastMod(long lastMod) { 
     28        this.lastMod = lastMod; 
     29    } 
     30     
    2631} 
  • trunk/pustefix-core/src/main/java/de/schlund/pfixxml/IncludePartsInfoFactory.java

    r6095 r6114  
    99public class IncludePartsInfoFactory { 
    1010     
    11     private Map<String, IncludePartsInfo> urisToInfo; 
    12     private boolean reloadable; 
     11    private final Map<String, IncludePartsInfo> urisToInfo; 
     12    private final boolean reloadable; 
    1313     
    1414    public IncludePartsInfoFactory() { 
    1515        urisToInfo = new HashMap<String, IncludePartsInfo>(); 
    1616        String mode = EnvironmentProperties.getProperties().getProperty("mode"); 
    17         if(mode != null && !mode.equals("prod")) reloadable = true; 
     17        reloadable = !"prod".equals(mode); 
    1818    } 
    1919     
     
    2828    public IncludePartsInfo getIncludePartsInfo(Resource resource) throws IncludePartsInfoParsingException { 
    2929        String uri = resource.toURI().toString(); 
    30         IncludePartsInfo info = urisToInfo.get(uri); 
     30        IncludePartsInfo info = null; 
     31        synchronized(urisToInfo) { 
     32            info = urisToInfo.get(uri); 
     33        } 
    3134        if(info == null || (reloadable && (info.getLastMod() < resource.lastModified()))) { 
    3235            info = IncludePartsInfoParser.parse(resource); 
    33             urisToInfo.put(uri, info); 
     36            synchronized(urisToInfo) { 
     37                urisToInfo.put(uri, info); 
     38            } 
    3439        } 
    3540        return info; 
     
    3742     
    3843    public void reset() { 
    39         urisToInfo.clear(); 
     44        synchronized(urisToInfo) { 
     45            urisToInfo.clear(); 
     46        } 
    4047    } 
    4148     
  • trunk/pustefix-core/src/main/java/de/schlund/pfixxml/IncludePartsInfoParser.java

    r5788 r6114  
    4444            throw new IncludePartsInfoParsingException(source.getSystemId(), x); 
    4545        } 
    46         IncludePartsInfo info = new IncludePartsInfo(); 
    47         info.setParts(handler.getParts()); 
    48         return info; 
     46        return new IncludePartsInfo(handler.getParts()); 
    4947    } 
    5048     
     
    5351        private int level; 
    5452        private boolean isIncludeParts; 
     53         
     54        private IncludePartInfo currentInfo; 
     55         
    5556        private Map<String, IncludePartInfo> includePartInfos = new HashMap<String, IncludePartInfo>(); 
    5657         
     
    6667                    isIncludeParts = true; 
    6768                } 
    68             } else if(level == 2 && isIncludeParts) { 
    69                 if(localName.equals("part")) { 
    70                     String partName = attributes.getValue("name"); 
    71                     if(partName != null) { 
    72                         partName = partName.trim(); 
    73                         boolean render = false; 
    74                         String val = attributes.getValue("render"); 
    75                         if(val != null) { 
    76                             render = Boolean.parseBoolean(val); 
     69            } else if(isIncludeParts) { 
     70                if(level == 2) { 
     71                    if(localName.equals("part")) { 
     72                        String partName = attributes.getValue("name"); 
     73                        if(partName != null) { 
     74                            partName = partName.trim(); 
     75                            boolean render = false; 
     76                            String val = attributes.getValue("render"); 
     77                            if(val != null) { 
     78                                render = Boolean.parseBoolean(val); 
     79                            } 
     80                            String[] variants = null; 
     81                            val = attributes.getValue("render-variants"); 
     82                            if(val != null) { 
     83                                val = val.trim(); 
     84                                variants = val.split("\\s+"); 
     85                            } 
     86                            Set<String> variantSet = new HashSet<String>(); 
     87                            if(variants != null) { 
     88                                for(String variant: variants) variantSet.add(variant); 
     89                            } 
     90                            currentInfo = new IncludePartInfo(partName, render, variantSet); 
     91                            includePartInfos.put(partName, currentInfo); 
    7792                        } 
    78                         String[] variants = null; 
    79                         val = attributes.getValue("render-variants"); 
    80                         if(val != null) { 
    81                             val = val.trim(); 
    82                             variants = val.split("\\s+"); 
     93                    } 
     94                } else if(level == 3) { 
     95                    if(localName.equals("theme")) { 
     96                        String themeName = attributes.getValue("name"); 
     97                        if(themeName != null) { 
     98                            themeName = themeName.trim(); 
     99                            currentInfo.addTheme(themeName); 
    83100                        } 
    84                         Set<String> variantSet = new HashSet<String>(); 
    85                         if(variants != null) { 
    86                             for(String variant: variants) variantSet.add(variant); 
    87                         } 
    88                         IncludePartInfo info = new IncludePartInfo(partName, render, variantSet); 
    89                         includePartInfos.put(partName, info); 
    90101                    } 
    91102                } 
  • trunk/pustefix-core/src/main/java/de/schlund/pfixxml/resources/DynamicResourceProvider.java

    r5849 r6114  
    226226    } 
    227227     
     228    public IncludePartsInfoFactory getIncludePartsInfoFactory() { 
     229        return incInfo; 
     230    } 
     231     
    228232} 
  • trunk/pustefix-core/src/main/java/de/schlund/pfixxml/targets/TargetGenerator.java

    r6095 r6114  
    8383import de.schlund.pfixxml.event.ConfigurationChangeListener; 
    8484import de.schlund.pfixxml.resources.DocrootResource; 
     85import de.schlund.pfixxml.resources.DynamicResourceProvider; 
    8586import de.schlund.pfixxml.resources.FileResource; 
    8687import de.schlund.pfixxml.resources.ModuleResource; 
    8788import de.schlund.pfixxml.resources.Resource; 
    8889import de.schlund.pfixxml.resources.ResourceFinder; 
     90import de.schlund.pfixxml.resources.ResourceProviderRegistry; 
    8991import de.schlund.pfixxml.resources.ResourceUtil; 
    9092import de.schlund.pfixxml.resources.ResourceVisitor; 
     
    210212        sharedLeafFactory = new SharedLeafFactory(); 
    211213        pageInfoFactory = new PageInfoFactory(); 
    212         includePartsInfo = new IncludePartsInfoFactory(); 
     214        includePartsInfo = ((DynamicResourceProvider)ResourceProviderRegistry.getResourceProvider("dynamic")).getIncludePartsInfoFactory(); 
    213215        Meminfo meminfo = new Meminfo(); 
    214216        meminfo.print("TG: Before loading " + config_path.toString()); 
  • trunk/pustefix-core/src/main/resources/PUSTEFIX-INF/xsl/include.xsl

    r5941 r6114  
    471471        </xsl:choose> 
    472472      </ixsl:with-param> 
    473       <xsl:if test="@module"> 
    474         <ixsl:with-param name="module"><xsl:value-of select="@module"/></ixsl:with-param> 
    475       </xsl:if> 
     473      <ixsl:with-param name="module"> 
     474        <xsl:choose> 
     475          <xsl:when test="@module"> 
     476            <xsl:value-of select="@module"/> 
     477          </xsl:when> 
     478          <xsl:otherwise> 
     479            <xsl:value-of select="include:getModuleFromSystemId()"/> 
     480          </xsl:otherwise> 
     481        </xsl:choose> 
     482      </ixsl:with-param> 
    476483      <xsl:if test="@search"> 
    477484        <ixsl:with-param name="search"><xsl:value-of select="@search"/></ixsl:with-param> 
     
    479486    </ixsl:call-template> 
    480487  </xsl:template> 
     488 
     489  <xsl:template match="pfx:checkinclude"> 
     490    <xsl:param name="part"><xsl:value-of select="@part"/></xsl:param> 
     491    <xsl:param name="href"><xsl:value-of select="@href"/></xsl:param> 
     492    <xsl:param name="module"><xsl:value-of select="@module"/></xsl:param> 
     493    <xsl:param name="search"><xsl:value-of select="@search"/></xsl:param> 
     494    <xsl:variable name="module_name"> 
     495      <xsl:choose> 
     496        <xsl:when test="@module='PAGEDEF' or @module='pagedef'"> 
     497          <xsl:value-of select="$__defining_module"/> 
     498        </xsl:when> 
     499        <xsl:otherwise> 
     500          <xsl:value-of select="$module"/> 
     501        </xsl:otherwise> 
     502      </xsl:choose> 
     503    </xsl:variable> 
     504    <xsl:variable name="realpath"> 
     505      <xsl:choose> 
     506        <xsl:when test="not($href='')"> 
     507          <xsl:value-of select="$href"/> 
     508        </xsl:when> 
     509        <xsl:otherwise> 
     510          <xsl:value-of select="include:getRelativePathFromSystemId()"/> 
     511        </xsl:otherwise> 
     512      </xsl:choose> 
     513    </xsl:variable> 
     514    <xsl:if test="include:exists($realpath, $part, $__target_gen, $__target_key, $module, $search, $tenant, $lang)"> 
     515      <xsl:apply-templates/> 
     516    </xsl:if> 
     517  </xsl:template> 
     518 
     519  <xsl:template match="pfx:checkinclude[@level='runtime']"> 
     520    <ixsl:if test="true()"> 
     521      <ixsl:variable name="_href_"> 
     522        <xsl:choose> 
     523          <xsl:when test="pfx:href"> 
     524            <xsl:apply-templates select="pfx:href/node()"/> 
     525          </xsl:when> 
     526          <xsl:when test="@href"> 
     527            <xsl:value-of select="@href"/> 
     528          </xsl:when> 
     529          <xsl:otherwise> 
     530            <xsl:value-of select="include:getRelativePathFromSystemId()"/> 
     531          </xsl:otherwise> 
     532        </xsl:choose> 
     533      </ixsl:variable> 
     534      <ixsl:variable name="_part_"> 
     535        <xsl:choose> 
     536          <xsl:when test="pfx:part"> 
     537            <xsl:apply-templates select="pfx:part/node()"/> 
     538          </xsl:when> 
     539          <xsl:otherwise> 
     540            <xsl:value-of select="@part"/> 
     541          </xsl:otherwise> 
     542        </xsl:choose> 
     543      </ixsl:variable> 
     544      <ixsl:variable name="_module_"> 
     545        <xsl:choose> 
     546          <xsl:when test="@module"> 
     547            <xsl:value-of select="module"/> 
     548          </xsl:when> 
     549          <xsl:otherwise> 
     550            <xsl:value-of select="include:getModuleFromSystemId()"/> 
     551          </xsl:otherwise> 
     552        </xsl:choose> 
     553      </ixsl:variable> 
     554      <ixsl:if test="pfx:checkInclude($_href_, $_part_, $_module_, '{@search}')"> 
     555        <xsl:apply-templates/> 
     556      </ixsl:if> 
     557    </ixsl:if> 
     558  </xsl:template> 
     559 
     560  <xsl:template match="pfx:checknoinclude"> 
     561    <xsl:param name="part"><xsl:value-of select="@part"/></xsl:param> 
     562    <xsl:param name="href"><xsl:value-of select="@href"/></xsl:param> 
     563    <xsl:param name="module"><xsl:value-of select="@module"/></xsl:param> 
     564    <xsl:param name="search"><xsl:value-of select="@search"/></xsl:param> 
     565    <xsl:variable name="module_name"> 
     566      <xsl:choose> 
     567        <xsl:when test="@module='PAGEDEF' or @module='pagedef'"> 
     568          <xsl:value-of select="$__defining_module"/> 
     569        </xsl:when> 
     570        <xsl:otherwise> 
     571          <xsl:value-of select="$module"/> 
     572        </xsl:otherwise> 
     573      </xsl:choose> 
     574    </xsl:variable> 
     575    <xsl:variable name="realpath"> 
     576      <xsl:choose> 
     577        <xsl:when test="not($href='')"> 
     578          <xsl:value-of select="$href"/> 
     579        </xsl:when> 
     580        <xsl:otherwise> 
     581          <xsl:value-of select="include:getRelativePathFromSystemId()"/> 
     582        </xsl:otherwise> 
     583      </xsl:choose> 
     584    </xsl:variable> 
     585    <xsl:if test="not(include:exists($realpath, $part, $__target_gen, $__target_key, $module, $search, $tenant, $lang))"> 
     586      <xsl:apply-templates/> 
     587    </xsl:if> 
     588  </xsl:template> 
     589 
     590  <xsl:template match="pfx:checknoinclude[@level='runtime']"> 
     591    <ixsl:if test="true()"> 
     592      <ixsl:variable name="_href_"> 
     593        <xsl:choose> 
     594          <xsl:when test="pfx:href"> 
     595            <xsl:apply-templates select="pfx:href/node()"/> 
     596          </xsl:when> 
     597          <xsl:when test="@href"> 
     598            <xsl:value-of select="@href"/> 
     599          </xsl:when> 
     600          <xsl:otherwise> 
     601            <xsl:value-of select="include:getRelativePathFromSystemId()"/> 
     602          </xsl:otherwise> 
     603        </xsl:choose> 
     604      </ixsl:variable> 
     605      <ixsl:variable name="_part_"> 
     606        <xsl:choose> 
     607          <xsl:when test="pfx:part"> 
     608            <xsl:apply-templates select="pfx:part/node()"/> 
     609          </xsl:when> 
     610          <xsl:otherwise> 
     611            <xsl:value-of select="@part"/> 
     612          </xsl:otherwise> 
     613        </xsl:choose> 
     614      </ixsl:variable> 
     615      <ixsl:variable name="_module_"> 
     616        <xsl:choose> 
     617          <xsl:when test="@module"> 
     618            <xsl:value-of select="module"/> 
     619          </xsl:when> 
     620          <xsl:otherwise> 
     621            <xsl:value-of select="include:getModuleFromSystemId()"/> 
     622          </xsl:otherwise> 
     623        </xsl:choose> 
     624      </ixsl:variable> 
     625      <ixsl:if test="not(pfx:checkInclude($_href_, $_part_, $_module_, '{@search}'))"> 
     626        <xsl:apply-templates/> 
     627      </ixsl:if> 
     628    </ixsl:if> 
     629  </xsl:template> 
     630   
     631  <xsl:template match="pfx:href"/> 
     632  <xsl:template match="pfx:part"/> 
    481633 
    482634  <xsl:template name="pfx:image_register_src"> 
     
    682834  </func:function> 
    683835  
     836  <func:function name="pfx:checkInclude"> 
     837    <xsl:param name="href"/> 
     838    <xsl:param name="part"/> 
     839    <xsl:param name="module"/> 
     840    <xsl:param name="search"/> 
     841    <func:result select="include:exists($href, $part, $__target_gen, $__target_key, $module, $search, $tenant, $lang)"/> 
     842  </func:function> 
     843  
    684844</xsl:stylesheet>