Cleaning the algorithm to compute friendly local names.
This commit is contained in:
parent
cfaf8ae9c2
commit
bf2980567a
|
@ -11,16 +11,41 @@
|
||||||
|
|
||||||
<xsl:variable name="source" select="/"/>
|
<xsl:variable name="source" select="/"/>
|
||||||
|
|
||||||
|
<xsl:variable name="common-extensions">
|
||||||
|
<content-type name="application/x-shockwave-flash">
|
||||||
|
<extension>swf</extension>
|
||||||
|
</content-type>
|
||||||
|
</xsl:variable>
|
||||||
|
|
||||||
|
<xsl:key name="extension" match="content-type" use="@name"/>
|
||||||
|
|
||||||
|
<xsl:function name="owk:add-extension" as="xs:string">
|
||||||
|
<xsl:param name="entry" as="element(entry)"/>
|
||||||
|
<xsl:param name="last-token" as="xs:string"/>
|
||||||
|
<xsl:sequence select="
|
||||||
|
if (contains($last-token, '.'))
|
||||||
|
then ''
|
||||||
|
else concat('.',
|
||||||
|
if (key('extension', $entry/content-type, $common-extensions))
|
||||||
|
then key('extension', $entry/content-type, $common-extensions)
|
||||||
|
else if (contains($entry/content-type, '/'))
|
||||||
|
then substring-after($entry/content-type, '/')
|
||||||
|
else 'unknown') "/>
|
||||||
|
</xsl:function>
|
||||||
|
|
||||||
|
|
||||||
<xsl:function name="owk:local-name" as="xs:string">
|
<xsl:function name="owk:local-name" as="xs:string">
|
||||||
<xsl:param name="entry" as="element(entry)"/>
|
<xsl:param name="entry" as="element(entry)"/>
|
||||||
<xsl:variable name="is-seed" select="$entry/discovery-path='-'"/>
|
<xsl:variable name="is-seed" select="$entry/discovery-path='-'"/>
|
||||||
<xsl:variable name="tokens" select="tokenize($entry/uri, '/')"/>
|
<xsl:variable name="tokens" select="tokenize(if (contains($entry/uri, '?')) then substring-before($entry/uri, '?') else $entry/uri, '/')"/>
|
||||||
<xsl:sequence
|
<xsl:sequence
|
||||||
select="if ($is-seed)
|
select="if ($is-seed)
|
||||||
then 'index.html'
|
then 'index.html'
|
||||||
else concat($tokens[3], '/', if ($tokens[last()] = '')
|
else concat(
|
||||||
then concat('index.', substring-after($entry/content-type, '/') )
|
$tokens[3],
|
||||||
else $tokens[last()])"
|
'/',
|
||||||
|
if ($tokens[last()] = '') then 'index' else $tokens[last()],
|
||||||
|
owk:add-extension($entry, $tokens[last()]))"
|
||||||
/>
|
/>
|
||||||
</xsl:function>
|
</xsl:function>
|
||||||
|
|
||||||
|
@ -32,11 +57,12 @@
|
||||||
then $local-name
|
then $local-name
|
||||||
else concat(
|
else concat(
|
||||||
substring-before($local-name, '/'),
|
substring-before($local-name, '/'),
|
||||||
substring-before(concat(substring-after($local-name, '/'), '.'), '.'),
|
'/',
|
||||||
|
substring-before(substring-after($local-name, '/'), '.'),
|
||||||
|
'-',
|
||||||
count($entry/preceding-sibling::entry[owk:local-name(.) = $local-name]) + 1,
|
count($entry/preceding-sibling::entry[owk:local-name(.) = $local-name]) + 1,
|
||||||
if (contains(substring-after($local-name, '/'), '.'))
|
'.',
|
||||||
then concat(substring-after(substring-after($local-name, '/'), '.'), '.')
|
substring-after(substring-after($local-name, '/'), '.')
|
||||||
else ''
|
|
||||||
)"
|
)"
|
||||||
/>
|
/>
|
||||||
</xsl:function>
|
</xsl:function>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -14,7 +14,7 @@
|
||||||
<xsl:with-param name="id" select="uri"/>
|
<xsl:with-param name="id" select="uri"/>
|
||||||
<xsl:with-param name="nodes1">
|
<xsl:with-param name="nodes1">
|
||||||
<local-name>
|
<local-name>
|
||||||
<xsl:value-of select="owk:local-name(key('log-by-uri', current()/uri, $source ))"/>
|
<xsl:value-of select="owk:unique-local-name(key('log-by-uri', current()/uri, $source ))"/>
|
||||||
</local-name>
|
</local-name>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
<xsl:with-param name="nodes2">
|
<xsl:with-param name="nodes2">
|
||||||
|
|
Loading…
Reference in New Issue