home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / sitemap2descr.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  28.0 KB  |  633 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17.  
  18. <!-- OLD FILE, not used anymore. Will be deleted soon. -->
  19.  
  20. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  21.     
  22.     <xsl:output indent="yes"/>
  23.     
  24.     <xsl:param name="location"/>
  25.     
  26.     <xsl:variable name="sitemapInfo" select="//SitemapInfo"/>
  27.     <xsl:variable name="globals" select="0"/>
  28.     <xsl:variable name="nomatch" select="'::::*****:::::'"/>
  29.     
  30.     <xsl:template match="/">
  31.         <sitemap location="{$location}"  >
  32.             <info>
  33.                 <xsl:call-template name="normalize-path">
  34.                     <xsl:with-param name="path"  select="'123/hoep/..'"/>
  35.                 </xsl:call-template>
  36.             </info>
  37.             <xsl:apply-templates/>
  38.         </sitemap>
  39.     </xsl:template>
  40.     
  41.     
  42.     <xsl:template match="map:components|map:views|map:component-configurations">
  43.     </xsl:template>
  44.     
  45.     
  46.     <xsl:template match="map:match" mode="print">
  47.         <xsl:param name="use_cnt" select="-1"/>
  48.         <xsl:param name="depth"  select="0"/>
  49.  
  50.         <match pattern="{@pattern}">
  51.             <xsl:if test="$use_cnt>0">
  52.                 <xsl:attribute name="used"><xsl:value-of select="$use_cnt"/></xsl:attribute>
  53.             </xsl:if>
  54.             <xsl:apply-templates>
  55.                 <xsl:with-param name="depth"  select="$depth+1"/>        
  56.             </xsl:apply-templates>
  57.         </match>
  58.     </xsl:template>
  59.     
  60.     
  61.     <xsl:template match="map:match">
  62.         <xsl:param name="depth"  select="0"/>
  63.  
  64.         <xsl:variable name="cnt_direct" select="count(//*[@src=concat('cocoon:/',current()/@pattern)])"/>
  65.         <xsl:variable name="indirects" select="$sitemapInfo//*[@pattern=current()/@pattern]"/>
  66.         <xsl:variable name="cnt_indirect">
  67.             <xsl:call-template name="cnt_indirect">
  68.                 <xsl:with-param name="indirects" select="$indirects"/>
  69.             </xsl:call-template>
  70.         </xsl:variable>
  71.         <xsl:if test="$cnt_direct+$cnt_indirect != 1">
  72.             <xsl:apply-templates select="." mode="print">
  73.                 <xsl:with-param name="use_cnt" select="$cnt_direct+$cnt_indirect"/>
  74.                 <xsl:with-param name="depth"  select="$depth+1"/>        
  75.             </xsl:apply-templates>
  76.         </xsl:if>
  77.     </xsl:template>
  78.     
  79.     
  80.     <xsl:template match="map:resource" mode="pipeline">
  81.         <xsl:param name="depth"  select="0"/>
  82.  
  83.         <xsl:element name="{substring-after(name(),'map:')}">
  84.             <xsl:copy-of select="@*"/>
  85.              <xsl:apply-templates />
  86.         </xsl:element>
  87.         
  88.         
  89.     </xsl:template>
  90.             
  91.     <xsl:template match="map:match" mode="pipeline">
  92.         <xsl:param name="depth"  select="0"/>
  93.  
  94.         <xsl:choose>
  95.             <xsl:when test="not($globals)">
  96.                 <xsl:apply-templates select="." mode="print">
  97.                             <xsl:with-param name="depth"  select="$depth+1"/>        
  98.                 </xsl:apply-templates>
  99.             </xsl:when>
  100.             
  101.             <xsl:otherwise>
  102.                 <!-- kijken hoe vaak deze match gebruikt wordt... -->
  103.                 <xsl:variable name="cnt_direct" select="count(//*[@src=concat('cocoon:/',current()/@pattern)])"/>
  104.                 <xsl:variable name="indirects" select="$sitemapInfo//*[@pattern=current()/@pattern]"/>
  105.                 <xsl:variable name="cnt_indirect">
  106.                     <xsl:call-template name="cnt_indirect">
  107.                         <xsl:with-param name="indirects" select="$indirects"/>
  108.                     </xsl:call-template>
  109.                 </xsl:variable>
  110.  
  111.                 <xsl:choose>
  112.                     <xsl:when test="$cnt_direct+$cnt_indirect < 2">
  113.                         <xsl:apply-templates select="." mode="print">
  114.                             <xsl:with-param name="use_cnt" select="$cnt_direct+$cnt_indirect"/>
  115.                             <xsl:with-param name="depth"  select="$depth+1"/>        
  116.                         </xsl:apply-templates>
  117.                     </xsl:when>
  118.                     <xsl:otherwise>
  119.                         <match ref="{@pattern}"/>
  120.                     </xsl:otherwise>
  121.                 </xsl:choose>
  122.  
  123.             </xsl:otherwise>
  124.         </xsl:choose>
  125.     </xsl:template>
  126.  
  127.     
  128.     
  129.     <xsl:template match="map:redirect-to">
  130.         <xsl:param name="depth"  select="0"/>
  131.  
  132.         <xsl:variable name="redirectname">
  133.             <xsl:call-template name="redirectpath">
  134.                 <xsl:with-param name="file" select="@uri"/>
  135.                 <xsl:with-param name="parentfile" select="../@pattern"/>
  136.             </xsl:call-template>
  137.         </xsl:variable>
  138.         <redirect to="{@uri}" src="{@uri}">
  139.             <xsl:apply-templates mode="pipeline" select=".">
  140.                 <xsl:with-param name="depth"  select="$depth+1"/>        
  141.                 <xsl:with-param name="redirectname" select="$redirectname"/>
  142.             </xsl:apply-templates>
  143.         </redirect>
  144.     </xsl:template>
  145.     
  146.     
  147.     <xsl:template match="map:view"/>
  148.     
  149.     
  150.     <xsl:template match="map:serialize">
  151.         <serialize>
  152.             <xsl:copy-of select="@*"/>
  153.         </serialize>
  154.     </xsl:template>
  155.     
  156.     
  157.     <xsl:template match="map:aggregate">
  158.         <aggregate>
  159.             <xsl:copy-of select="@element"/>
  160.             <xsl:apply-templates/>
  161.         </aggregate>
  162.     </xsl:template>
  163.     
  164.     
  165.     
  166.     
  167.     <xsl:template match="*" mode="pipeline">
  168.         <xsl:param name="redirectname"/>
  169.         <xsl:param name="depth"  select="0"/>
  170.         
  171.         <xsl:variable name="src">
  172.             <xsl:if test="not(contains(@src,'cocoon:/'))">cocoon:/</xsl:if>
  173.             <xsl:choose>
  174.                 <xsl:when test="contains($redirectname,'?')">
  175.                     <xsl:value-of select="substring-before($redirectname,'?')"/>
  176.                 </xsl:when>
  177.                 <xsl:when test="$redirectname!=''">
  178.                     <xsl:value-of select="$redirectname"/>
  179.                 </xsl:when>
  180.                 <xsl:when test="contains(concat(@src,@uri),'?')">
  181.                     <xsl:value-of select="substring-before(concat(@src,@uri),'?')"/>
  182.                 </xsl:when>
  183.                 <xsl:otherwise>
  184.                     <xsl:value-of select="concat(@src,@uri)"/>
  185.                 </xsl:otherwise>
  186.             </xsl:choose>
  187.         </xsl:variable>
  188.         
  189.         <xsl:if test="$depth < 100">
  190.  
  191.             <xsl:element name="{substring-after(name(),'map:')}">
  192.             <xsl:attribute name="src"><xsl:value-of select="concat(@src,@uri)"/></xsl:attribute>
  193.                 <xsl:copy-of select="@element|@type|@mime-type"/>
  194.                 <xsl:variable name="src0">
  195.                     <xsl:call-template name="skip-interparam-slashes">
  196.                         <xsl:with-param name="str" select="substring-after($src,'cocoon:/')"/>
  197.                     </xsl:call-template>
  198.                 </xsl:variable> 
  199.                 <xsl:variable name="thepattern">
  200.                     <xsl:call-template name="find-match">
  201.                         <xsl:with-param name="request" select="$src0"/>
  202.                     </xsl:call-template>
  203.                 </xsl:variable>
  204.                 <!--xsl:message>- found <xsl:value-of select="$thepattern"/></xsl:message-->
  205.                 <!--            
  206.                 <xsl:variable name="pattern-1" select="$sitemapInfo//*[@ref=$src0]/@pattern"/>
  207.                 <xsl:variable name="pattern-2" select="concat(substring-before(substring-after($src,'cocoon:/'),'{'),'*',substring-after($src,'}'))"/>
  208.                 <xsl:variable name="pattern-3" select="concat(substring-before(substring-after($src,'cocoon:/'),'{'),'**',substring-after($src,'}'))"/>
  209.                 <xsl:variable name="pattern-4" select="concat('**',substring-before(substring-after($src,'cocoon:/'),'{'),'**',substring-after($src,'}'))"/>
  210.                 <xsl:variable name="pattern-5" select="concat(substring-before(substring-after($src,'cocoon:/'),'/'),'/*.',substring-after($src,'.'))"/>
  211.                 <xsl:variable name="pattern-6" select="concat(substring-before(substring-after($src,'cocoon:/'),'/'),'*.',substring-after($src,'.'))"/>
  212.                 <xsl:variable name="pattern-7" select="concat(substring-before(substring-after($src,'cocoon:/'),'/'),'/**')"/>
  213.                 
  214.                 <xsl:variable name="pattern-8" select="concat(substring-before(substring-after($src,'cocoon:/'),'xdocs'),'xdocs/**book',substring-after($src,'/book'))"/>
  215.     
  216.                 <xsl:variable name="pattern-9" select="concat('**',substring-before(substring-after($src,'cocoon:/'),'{1}/'),
  217.                     substring-before(substring-after($src,'{1}/'),'{1}'),'**',substring-before(substring-after(substring-after($src,'{1}'),'{1}'),'{2}'),'*',
  218.                     substring-after($src,'{2}'),
  219.                 '')"/>
  220.     -->
  221.                 <xsl:choose>
  222.                     <xsl:when test="count(//map:match[@pattern=$thepattern])>0">
  223.                         <xsl:apply-templates select="//map:match[@pattern=$thepattern]" mode="pipeline">
  224.                             <xsl:with-param name="depth" select="$depth+1"/>
  225.                         </xsl:apply-templates>
  226.                     </xsl:when>
  227.                     <!--
  228.                     <xsl:when test="count(//map:match[@pattern=$src0 or @pattern=$pattern-1 or @pattern=$pattern-2])>0">
  229.                         <xsl:apply-templates select="//map:match[ @pattern=substring-after($src,'cocoon:/') or @pattern=$pattern-1 or @pattern=$pattern-2]" mode="pipeline"/>
  230.                     </xsl:when>
  231.                     <xsl:when test="count(//map:match[@pattern=concat('*.',substring-after($src,'.'))])>0">
  232.                         <xsl:apply-templates select="//map:match[@pattern=concat('*.',substring-after($src,'.'))]" mode="pipeline"/>
  233.                     </xsl:when>
  234.                     <xsl:when test="count(//map:match[@pattern=$pattern-3])>0">
  235.                         <xsl:apply-templates select="//map:match[ @pattern=$pattern-3]" mode="pipeline"/>
  236.                     </xsl:when>
  237.                     <xsl:when test="count(//map:match[@pattern=$pattern-4])>0">
  238.                         <xsl:apply-templates select="//map:match[ @pattern=$pattern-4]" mode="pipeline"/>
  239.                     </xsl:when>
  240.                     <xsl:when test="count(//map:match[@pattern=$pattern-5])>0">
  241.                         <xsl:apply-templates select="//map:match[ @pattern=$pattern-5]" mode="pipeline"/>
  242.                     </xsl:when>
  243.                     <xsl:when test="count(//map:match[@pattern=$pattern-6])>0">
  244.                         <xsl:apply-templates select="//map:match[ @pattern=$pattern-6]" mode="pipeline"/>
  245.                     </xsl:when>
  246.                     <xsl:when test="count(//map:match[@pattern=$pattern-7])>0">
  247.                         <xsl:apply-templates select="//map:match[ @pattern=$pattern-7]" mode="pipeline"/>
  248.                     </xsl:when>
  249.                     <xsl:when test="count(//map:match[@pattern=$pattern-8])>0">
  250.                         <xsl:apply-templates select="//map:match[ @pattern=$pattern-8]" mode="pipeline"/>
  251.                     </xsl:when>
  252.                     <xsl:when test="count(//map:match[@pattern=$pattern-9])>0">
  253.                         <xsl:apply-templates select="//map:match[ @pattern=$pattern-9]" mode="pipeline"/>
  254.                     </xsl:when>
  255.     -->
  256.                     <xsl:otherwise>
  257.                         <xsl:variable name="empty">
  258.                             <xsl:call-template name="find-match">
  259.                                 <xsl:with-param name="request" select="$src0"/>
  260.                             </xsl:call-template>
  261.                         </xsl:variable>
  262.                         <LEGEPIPELINE src="{$src}">
  263.                             <pattern>
  264.                                 <xsl:copy-of select="$thepattern"/>
  265.                             </pattern>
  266.                             <!--
  267.                             <pattern>
  268.                                 <xsl:copy-of select="$pattern-1"/>
  269.                             </pattern>
  270.                             <pattern>
  271.                                 <xsl:value-of select="$pattern-2"/>
  272.                             </pattern>
  273.                             <pattern>
  274.                                 <xsl:value-of select="$pattern-3"/>
  275.                             </pattern>
  276.                             <pattern-9>
  277.                                 <xsl:value-of select="$pattern-9"/>
  278.                             </pattern-9>
  279.                             <pattern-8>
  280.                                 <xsl:value-of select="$pattern-8"/>
  281.                             </pattern-8>
  282.     -->
  283.                             <match ref="{substring-after($src,'cocoon:/')}" pattern="{concat(substring-before(substring-after($src,'cocoon:/'),'{'),substring-after($src,'}'))}"/>
  284.                         </LEGEPIPELINE>
  285.                     </xsl:otherwise>
  286.                 </xsl:choose>
  287.                 <!--xsl:apply-templates select="//map:match[ @pattern=substring-after($src,'cocoon:/') or @pattern=$pattern-1 or @pattern=$pattern-2]" mode="pipeline"/>
  288.     
  289.             <xsl:if test="count(//map:match[@pattern=substring-after($src,'cocoon:/') or @pattern=$pattern-1 or @pattern=$pattern-2])=0">
  290.                 <xsl:apply-templates select="//map:match[@pattern=concat('*.',substring-after($src,'.'))]" mode="pipeline"/>
  291.                     <xsl:if test="count(//map:match[@pattern=concat('*.',substring-after($src,'.'))])=0">
  292.                 
  293.                         <LEGEPIPELINE>
  294.                         <src><xsl:value-of select="$src"/></src>
  295.                         <pattern><xsl:copy-of select="$pattern-1"/></pattern>
  296.                         <pattern><xsl:value-of select="$pattern-2"/></pattern>
  297.                         
  298.                         <match ref="{substring-after($src,'cocoon:/')}" pattern="{concat(substring-before(substring-after($src,'cocoon:/'),'{'),substring-after($src,'}'))}"/>
  299.                         </LEGEPIPELINE>
  300.                 </xsl:if>
  301.             </xsl:if-->
  302.             </xsl:element>
  303.         </xsl:if>
  304.     </xsl:template>
  305.     
  306.     <xsl:template match="Sitemap|map:sitemap|map:pipelines|map:pipeline">
  307.         <xsl:param name="depth" select="0"/>
  308.         <xsl:apply-templates select="*">
  309.             <xsl:with-param name="depth" select="$depth+1"/>
  310.         </xsl:apply-templates>
  311.     </xsl:template>
  312.     
  313.     <xsl:template match="map:resources">
  314.     </xsl:template>
  315.    
  316.    
  317.      <xsl:template match="map:call">
  318.         <xsl:element name="{substring-after(name(),'map:')}">
  319.             <xsl:copy-of select="@*"/>
  320.              <xsl:apply-templates select="//map:resource[@name=current()/@resource]" mode="pipeline"/>
  321.         </xsl:element>
  322.     </xsl:template>
  323.    
  324.  
  325.  
  326.     <xsl:template match="map:generate|map:read|map:transform|map:part">
  327.         <xsl:param name="depth"  select="0"/>
  328.  
  329.         <xsl:choose>
  330.             <xsl:when test="contains(@src,'cocoon:/')">
  331.                 <xsl:apply-templates select="." mode="pipeline" >
  332.                     <xsl:with-param name="depth"  select="$depth+1"/>        
  333.                 </xsl:apply-templates>
  334.             </xsl:when>
  335.             <xsl:otherwise>
  336.                 <xsl:element name="{substring-after(name(),'map:')}">
  337.                     <xsl:copy-of select="@*"/>
  338.                     <xsl:apply-templates />
  339.                 </xsl:element>
  340.             </xsl:otherwise>
  341.         </xsl:choose>
  342.     </xsl:template>
  343.  
  344.     <xsl:template match="map:*">
  345.         <xsl:param name="depth"  select="0"/>
  346.  
  347.         <xsl:element name="{substring-after(name(),'map:')}">
  348.             <xsl:copy-of select="@*"/>
  349.             <xsl:apply-templates>
  350.                 <xsl:with-param name="depth" select="$depth +1"/>
  351.             </xsl:apply-templates>
  352.         </xsl:element>
  353.     </xsl:template>
  354.     
  355.     <xsl:template match="text()">
  356.         <xsl:apply-templates/>
  357.     </xsl:template>
  358.     
  359.     
  360.     <xsl:template name="cnt_indirect">
  361.         <xsl:param name="indirects"/>
  362.         <xsl:choose>
  363.             <xsl:when test="$indirects[1]">
  364.                 <xsl:variable name="count_this" select="count(//*[@src=concat('cocoon:/',$indirects[1]//@ref)])"/>
  365.                 <xsl:variable name="count_rest">
  366.                     <xsl:call-template name="cnt_indirect">
  367.                         <xsl:with-param name="indirects" select="$indirects[position()>1]"/>
  368.                     </xsl:call-template>
  369.                 </xsl:variable>
  370.                 <xsl:value-of select="$count_this + $count_rest"/>
  371.             </xsl:when>
  372.             <xsl:otherwise>0</xsl:otherwise>
  373.         </xsl:choose>
  374.     </xsl:template>
  375.     
  376.     
  377.     <xsl:template name="redirectpath">
  378.         <xsl:param name="file" select="@uri"/>
  379.         <xsl:param name="parentfile" select="../@pattern"/>
  380.         <xsl:choose>
  381.             <xsl:when test="contains($parentfile,'/')">
  382.                 <xsl:variable name="first-part" select="substring-before($parentfile,'/')"/>
  383.                 <xsl:variable name="rest-part">
  384.                     <xsl:call-template name="redirectpath">
  385.                         <xsl:with-param name="file" select="$file"/>
  386.                         <xsl:with-param name="parentfile" select="substring-after($parentfile,'/')"/>
  387.                     </xsl:call-template>
  388.                 </xsl:variable>
  389.                 <xsl:value-of select="concat($first-part,'/',$rest-part)"/>
  390.             </xsl:when>
  391.             <xsl:otherwise>
  392.                 <xsl:value-of select="$file"/>
  393.             </xsl:otherwise>
  394.         </xsl:choose>
  395.     </xsl:template>
  396.     
  397.     
  398.     
  399.     <!--xsl:template match="*.xxx">
  400.         <xsl:copy>
  401.             <xsl:copy-of select="@*"/>
  402.             <xsl:apply-templates/>
  403.         </xsl:copy>
  404.     </xsl:template-->
  405.  
  406.     
  407.     <xsl:template name="find-match">
  408.         <xsl:param name="request"/>
  409.         
  410.         <xsl:variable name="norm-req">
  411.             <xsl:call-template name="normalize-path">
  412.                 <xsl:with-param name="path" select="$request"/>
  413.             </xsl:call-template>
  414.         </xsl:variable>
  415.         <!--xsl:message>find-match for <xsl:value-of select="$request"/> or <xsl:value-of select="$norm-req"/></xsl:message-->
  416.         
  417.         
  418.         <xsl:choose>
  419.             <xsl:when test="//map:match[@pattern=$norm-req]">
  420.                 <xsl:value-of select="//map:match[@pattern=$norm-req]/@pattern"/>
  421.             </xsl:when>
  422.             <xsl:when test="substring($norm-req,1,3)='../'">
  423.                 <!-- try to find the request in the local dir, just in case -->
  424.                 <xsl:call-template name="find-match">
  425.                     <xsl:with-param name="request" select="substring-after($norm-req,'../')"/>
  426.                 </xsl:call-template>
  427.             </xsl:when>
  428.             <xsl:when test="contains($norm-req,'..')">
  429.                 <xsl:value-of select="$nomatch"/>
  430.             </xsl:when>
  431.             <xsl:otherwise>
  432.                 <xsl:call-template name="find-a-match">
  433.                     <xsl:with-param name="request" select="concat('',$norm-req)"/>
  434.                     <xsl:with-param name="matches" select="//map:match[contains(@pattern,'*')]"/>
  435.                 </xsl:call-template>
  436.             </xsl:otherwise>
  437.         </xsl:choose>
  438.     </xsl:template>
  439.     
  440.     
  441.     <xsl:template name="find-a-match">
  442.         <xsl:param name="request"/>
  443.         <xsl:param name="matches"/>
  444.         <xsl:choose>
  445.             <xsl:when test="count($matches)=0">
  446.                 <xsl:value-of select="$nomatch"/>
  447.             </xsl:when>
  448.             <xsl:otherwise>
  449.                 <xsl:variable name="first-test-result">
  450.                     <xsl:call-template name="test-match">
  451.                         <xsl:with-param name="pattern" select="concat('',$matches[1]/@pattern)"/>
  452.                         <xsl:with-param name="request" select="$request"/>
  453.                     </xsl:call-template>
  454.                 </xsl:variable>
  455.                 <xsl:choose>
  456.                     <xsl:when test="$first-test-result=1">
  457.                         <xsl:value-of select="$matches[1]/@pattern"/>
  458.                     </xsl:when>
  459.                     <xsl:otherwise>
  460.                         <xsl:call-template name="find-a-match">
  461.                             <xsl:with-param name="request" select="$request"/>
  462.                             <xsl:with-param name="matches" select="$matches[position()>1]"/>
  463.                         </xsl:call-template>
  464.                     </xsl:otherwise>
  465.                 </xsl:choose>
  466.             </xsl:otherwise>
  467.         </xsl:choose>
  468.     </xsl:template>
  469.  
  470.  
  471.     <xsl:template name="test-match">
  472.         <xsl:param name="pattern"/>
  473.         <xsl:param name="request"/>
  474.         <!--xsl:message>test-match</xsl:message>        
  475.     <xsl:message>- pattern: <xsl:value-of select="$pattern"/></xsl:message>        
  476.     <xsl:message>- request: <xsl:value-of select="$request"/></xsl:message-->
  477.  
  478.         <xsl:choose>
  479.             <xsl:when test="$pattern=$request">1</xsl:when>
  480.             <xsl:when test="not(contains($pattern,'*'))">0</xsl:when>
  481.             <xsl:when test="$request=''">0</xsl:when>
  482.             <!--xsl:when test="substring($pattern,1,1)='*'">
  483.                 <xsl:call-template name="test-match-anybefore">
  484.                     <xsl:with-param name="pattern" select="substring-after($pattern,'*')"/>
  485.                     <xsl:with-param name="request" select="$request"/>
  486.                 </xsl:call-template>
  487.             </xsl:when-->
  488.             <!--xsl:when test="substring($pattern,1,2)='**'">
  489.                 <xsl:message>UNSUPPORTED** </xsl:message>
  490.                 UNSUPPORTED**
  491.             </xsl:when-->
  492.  
  493.             <xsl:when test="substring($pattern,1,1)='*'">
  494.  
  495.                 <xsl:variable name="subtext">
  496.                     <xsl:choose>
  497.                         <xsl:when test="substring($pattern,1,2)='**' and contains(substring($pattern,3),'*')">
  498.                             <xsl:value-of select="substring-before(substring($pattern,3),'*')"/>
  499.                         </xsl:when>
  500.                         <xsl:when test="substring($pattern,1,2)='**' ">
  501.                             <xsl:value-of select="substring($pattern,3)"/>
  502.                         </xsl:when>
  503.                         <xsl:when test="contains(substring($pattern,2),'*')">
  504.                             <xsl:value-of select="substring-before(substring($pattern,2),'*')"/>
  505.                         </xsl:when>
  506.                         <xsl:otherwise>
  507.                             <xsl:value-of select="substring($pattern,2)"/>
  508.                         </xsl:otherwise>
  509.                     </xsl:choose>
  510.                 </xsl:variable>
  511.  
  512.                 <xsl:choose>
  513.                     <xsl:when test="$subtext=''">
  514.                         <xsl:value-of select="number(substring($pattern,2,2)='*' or not(contains($request,'/')))"/>
  515.                     </xsl:when>
  516.                     <xsl:when test="not(contains($request,$subtext))">0</xsl:when>
  517.                     <xsl:when test="not(substring($pattern,2,1)='*') and contains(substring-before($request,$subtext),'/')">0</xsl:when>
  518.                     <xsl:otherwise>
  519.                         <xsl:call-template name="test-match-anybefore">
  520.                             <xsl:with-param name="pattern" select="substring-after($pattern,$subtext)"/>
  521.                             <xsl:with-param name="request" select="substring-after($request,$subtext)"/>
  522.                         </xsl:call-template>
  523.                     </xsl:otherwise>
  524.                 </xsl:choose>
  525.             </xsl:when>
  526.  
  527.             <xsl:when test="substring($pattern,1,1)=substring($request,1,1)">
  528.                 <xsl:call-template name="test-match">
  529.                     <xsl:with-param name="pattern" select="substring($pattern,2)"/>
  530.                     <xsl:with-param name="request" select="substring($request,2)"/>
  531.                 </xsl:call-template>
  532.             </xsl:when>
  533.             <xsl:otherwise>
  534.                 0                
  535.             </xsl:otherwise>
  536.         </xsl:choose>
  537.     </xsl:template>
  538.     
  539.     
  540.     <xsl:template name="test-match-anybefore">
  541.         <xsl:param name="pattern"/>
  542.         <xsl:param name="request"/>
  543.         <xsl:variable name="isok">
  544.             <xsl:call-template name="test-match">
  545.                 <xsl:with-param name="pattern" select="$pattern"/>
  546.                 <xsl:with-param name="request" select="$request"/>
  547.             </xsl:call-template>
  548.         </xsl:variable>
  549.         <xsl:choose>
  550.             <xsl:when test="$isok=1">1</xsl:when>
  551.             <xsl:when test="string-length($request)=0">
  552.                 <xsl:choose>
  553.                     <xsl:when test="$pattern=''">1</xsl:when>
  554.                     <xsl:otherwise>0</xsl:otherwise>
  555.                 </xsl:choose>
  556.             </xsl:when>
  557.             <xsl:otherwise>
  558.                 <xsl:call-template name="test-match-anybefore">
  559.                     <xsl:with-param name="pattern" select="$pattern"/>
  560.                     <xsl:with-param name="request" select="substring($request,2)"/>
  561.                 </xsl:call-template>
  562.             </xsl:otherwise>
  563.         </xsl:choose>
  564.     </xsl:template>
  565.  
  566.  
  567.     <xsl:template name="skip-interparam-slashes">
  568.         <xsl:param name="str"/>
  569.  
  570.         <xsl:choose>
  571.             <xsl:when test="contains(substring-after($str,'{'),'/')">
  572.                 <xsl:value-of select="concat(substring-before($str,'{'),'{',translate(substring-before(substring-after($str,'{'),'}'),'/','|'),'}')"/>
  573.                 <xsl:call-template name="skip-interparam-slashes">
  574.                     <xsl:with-param name="str" select="substring-after($str,'}')"/>
  575.                 </xsl:call-template>
  576.             </xsl:when>
  577.             <xsl:otherwise>
  578.                 <xsl:value-of select="$str"/>
  579.             </xsl:otherwise>
  580.         </xsl:choose>
  581.         
  582.     </xsl:template>
  583.  
  584.  
  585.  
  586.     <xsl:template name="normalize-path">
  587.         <xsl:param name="path"/>
  588.         <!-- this will take care of paths like "/usr/local/../program/../../tmp" and change it into "/tmp" -->
  589.         <xsl:choose>
  590.             <xsl:when test="contains($path,'/../')">
  591.                 <xsl:variable name="first-part">
  592.                         <xsl:call-template name="strip-last-dir">
  593.                             <xsl:with-param name="path" select="substring-before($path,'/../')"/>
  594.                         </xsl:call-template>
  595.                 </xsl:variable>
  596.                 <xsl:call-template name="normalize-path">
  597.                     <xsl:with-param name="path" select="concat($first-part,substring-after($path,'/../'))"/>
  598.                 </xsl:call-template>
  599.             </xsl:when>
  600.             <xsl:when test="contains($path,'/..') and substring-after($path,'/..')='' ">
  601.                 <xsl:variable name="first-part">
  602.                         <xsl:call-template name="strip-last-dir">
  603.                             <xsl:with-param name="path" select="substring-before($path,'/..')"/>
  604.                         </xsl:call-template>
  605.                 </xsl:variable>
  606.                 <xsl:value-of select="substring($first-part,1,string-length($first-part)-1)"/>
  607.             </xsl:when>
  608.             <xsl:when test="contains($path,'/./')">
  609.                 <xsl:call-template name="normalize-path">
  610.                         <xsl:with-param name="path" select="concat(substring-before($path,'/./'),'/',substring-after($path,'/./'))"/>
  611.                 </xsl:call-template>
  612.             </xsl:when>
  613.             <xsl:otherwise><xsl:value-of select="$path"/></xsl:otherwise>
  614.         </xsl:choose>
  615.  
  616.     </xsl:template>
  617.     
  618.     <xsl:template name="strip-last-dir">
  619.         <xsl:param name="path"/>
  620.         <!-- this will change "/usr/local/me" into "/usr/local/", 
  621.             "usr/him" into "usr/" 
  622.             and "foo" into "" -->
  623.         
  624.         <xsl:if test="contains($path,'/')">
  625.             <xsl:value-of select="concat(substring-before($path,'/'),'/')"/>
  626.             <xsl:call-template name="strip-last-dir">
  627.                 <xsl:with-param name="path" select="substring-after($path,'/')"/>
  628.             </xsl:call-template>
  629.         </xsl:if>
  630.  
  631.     </xsl:template>
  632. </xsl:stylesheet>
  633.