1 | <!--
|
---|
2 | This file is part of the DITA Open Toolkit project hosted on
|
---|
3 | Sourceforge.net. See the accompanying license.txt file for
|
---|
4 | applicable licenses.
|
---|
5 |
|
---|
6 | (C) Copyright Shawn McKenzie, 2007. All Rights Reserved.
|
---|
7 | *-->
|
---|
8 | <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
---|
9 |
|
---|
10 |
|
---|
11 | <!-- this template will stip out funky chars used for js variable names -->
|
---|
12 | <xsl:template name="stripstring">
|
---|
13 | <xsl:param name="jsvarstring"/>
|
---|
14 | <!-- this should simply strip strange characters from the param so it can
|
---|
15 | be used as a JavaScript variable name -->
|
---|
16 |
|
---|
17 | <!-- can't use the following chars in xsl, so make vars -->
|
---|
18 | <xsl:variable name="apos">'</xsl:variable>
|
---|
19 | <xsl:variable name="comma">,</xsl:variable>
|
---|
20 | <xsl:variable name="colon">:</xsl:variable>
|
---|
21 | <xsl:variable name="gt">></xsl:variable>
|
---|
22 | <xsl:variable name="lt"><</xsl:variable>
|
---|
23 |
|
---|
24 | <xsl:value-of select="translate(translate(translate(translate(translate(translate($jsvarstring,
|
---|
25 | '/\^&|\¬`*.-) (%?$£!+=1234567890[]{}',
|
---|
26 | ''), $apos, ''), $comma, ''), $colon, ''), $gt, ''), $lt, '')"/>
|
---|
27 | <!-- above does not catch , ' or : -->
|
---|
28 |
|
---|
29 |
|
---|
30 | <!-- <xsl:variable name="self"
|
---|
31 | select="translate(translate(translate(@navtitle, '/', ''), '.', ''), ' ', '')"/>-->
|
---|
32 | </xsl:template>
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 | <xsl:template name="escapestring">
|
---|
40 | <xsl:param name="jstextstring"/>
|
---|
41 | <!-- this might need recursion. I'll need to escape chars in the output
|
---|
42 | so that these symbols , : ' (others?) look like \, \: \'
|
---|
43 | I might need recursion because there may be multiple instances of
|
---|
44 | these chars.-->
|
---|
45 |
|
---|
46 | <!-- can't use the following chars in xsl, so make vars -->
|
---|
47 | <xsl:variable name="apos">'</xsl:variable>
|
---|
48 | <xsl:variable name="jsapos">\'</xsl:variable>
|
---|
49 | <xsl:variable name="comma">,</xsl:variable>
|
---|
50 | <xsl:variable name="jscomma">\,</xsl:variable>
|
---|
51 | <xsl:variable name="colon">:</xsl:variable>
|
---|
52 | <xsl:variable name="jscolon">\:</xsl:variable>
|
---|
53 |
|
---|
54 |
|
---|
55 | <!-- use the strip for testing and escape later -->
|
---|
56 | <xsl:value-of select="translate(translate(translate($jstextstring, '/\^&|\¬`*?.-) (%$£!+=', ''),
|
---|
57 | $apos, ''), $comma, '')"/>/>
|
---|
58 | </xsl:template>
|
---|
59 |
|
---|
60 | </xsl:stylesheet>
|
---|