source: archiver/pipelines/test/common-rewrite.xsl @ 5acb101

Revision 5acb101, 4.2 KB checked in by Eric van der Vlist <vdv@dyomedea.com>, 10 years ago (diff)

Rewriting resources with no archived out links

  • Property mode set to 100644
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl" xmlns:xsltu="http://xsltunit.org/0/"
3  xmlns:owk="http://owark.org/xslt/" exclude-result-prefixes="exsl">
4  <xsl:import href="../actions/mediatypes/common-rewrite.xsl"/>
5  <xsl:import href="xsltunit.xsl"/>
6  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
7  <xsl:variable name="index" select="doc('local-names.xml')/index"/>
8  <xsl:variable name="resource" select="$index/resource[uri='http://gmpg.org/xfn/11']"/>
9  <xsl:key name="log-by-uri" match="/log/entry" use="uri"/>
10  <xsl:template match="/">
11    <xsltu:tests>
12      <xsltu:test id="is-relative1">
13        <xsl:call-template name="xsltu:assertEqual">
14          <xsl:with-param name="id" select="'is-relative'"/>
15          <xsl:with-param name="nodes1">
16            <is-relative>true</is-relative>
17          </xsl:with-param>
18          <xsl:with-param name="nodes2">
19            <is-relative>
20              <xsl:value-of select="owk:is-relative('/foo')"/>
21            </is-relative>
22          </xsl:with-param>
23        </xsl:call-template>
24      </xsltu:test>
25      <xsltu:test id="is-relative2">
26        <xsl:call-template name="xsltu:assertEqual">
27          <xsl:with-param name="id" select="'is-relative'"/>
28          <xsl:with-param name="nodes1">
29            <is-relative>false</is-relative>
30          </xsl:with-param>
31          <xsl:with-param name="nodes2">
32            <is-relative>
33              <xsl:value-of select="owk:is-relative('http://example.com/foo')"/>
34            </is-relative>
35          </xsl:with-param>
36        </xsl:call-template>
37      </xsltu:test>
38      <xsltu:test id="safer-resolve-uri1">
39        <xsl:call-template name="xsltu:assertEqual">
40          <xsl:with-param name="id" select="'is-relative'"/>
41          <xsl:with-param name="nodes1">
42            <uri>http://example.com/foo</uri>
43          </xsl:with-param>
44          <xsl:with-param name="nodes2">
45            <uri>
46              <xsl:value-of select="owk:safer-resolve-uri('/foo', 'http://example.com/')"/>
47            </uri>
48          </xsl:with-param>
49        </xsl:call-template>
50      </xsltu:test>
51      <xsltu:test id="safer-resolve-uri2">
52        <xsl:call-template name="xsltu:assertEqual">
53          <xsl:with-param name="id" select="'is-relative'"/>
54          <xsl:with-param name="nodes1">
55            <uri>http://owark.org/foo</uri>
56          </xsl:with-param>
57          <xsl:with-param name="nodes2">
58            <uri>
59              <xsl:value-of select="owk:safer-resolve-uri('http://owark.org/foo', 'http://example.com/')"/>
60            </uri>
61          </xsl:with-param>
62        </xsl:call-template>
63      </xsltu:test>
64      <xsltu:test id="safer-resolve-uri3">
65        <xsl:call-template name="xsltu:assertEqual">
66          <xsl:with-param name="id" select="'is-relative'"/>
67          <xsl:with-param name="nodes1">
68            <uri>http://owark.org/foo{{{{}}}}</uri>
69          </xsl:with-param>
70          <xsl:with-param name="nodes2">
71            <uri>
72              <xsl:value-of select="owk:safer-resolve-uri('http://owark.org/foo{{{{}}}}', 'http://example.com/')"/>
73            </uri>
74          </xsl:with-param>
75        </xsl:call-template>
76      </xsltu:test>
77      <xsltu:test id="url-rewrite">
78        <xsl:call-template name="xsltu:assertEqual">
79          <xsl:with-param name="id" select="'rewrite1'"/>
80          <xsl:with-param name="nodes1">
81            <uri>http://gmpg.org/foo</uri>
82          </xsl:with-param>
83          <xsl:with-param name="nodes2">
84            <uri>
85              <xsl:value-of select="owk:url-rewrite('/foo')"/>
86            </uri>
87          </xsl:with-param>
88        </xsl:call-template>
89        <xsl:call-template name="xsltu:assertEqual">
90          <xsl:with-param name="id" select="'rewrite2'"/>
91          <xsl:with-param name="nodes1">
92            <uri>../gmpg.org/11-1.html</uri>
93          </xsl:with-param>
94          <xsl:with-param name="nodes2">
95            <uri>
96              <xsl:value-of select="owk:url-rewrite('/xfn/11')"/>
97            </uri>
98          </xsl:with-param>
99        </xsl:call-template>
100      </xsltu:test>
101
102    </xsltu:tests>
103  </xsl:template>
104</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.