added Info.plist
[TestXSLT.git] / libsablot / README_JS
1 Sablotron XSLT Extensions Readme File
2 =====================================
3
4 1. Building
5 ----------------------------------------
6
7 Extension elements and functions as defined by XSLT 1.0 are 
8 implemented in Sablotron since the version 0.80. Sablotron recognizes
9 the extension element <http://www.exslt.org/functions/script> as 
10 suggested by exslt.org. There are some exceptions described later in 
11 this document. Please note, that this feature is still supposed to be 
12 EXPERIMENTAL.
13
14 If you want to benefit form this feature, you have to install
15 JavaScript engine from mozilla.org (SpiderMonkey). You have to do it
16 even when you have Mozilla browser installed, because the binary
17 browser installation doesn't include essential header files.
18
19 An alternative way to get all neccessary JS files is to download and 
20 install Charlie application framework (see gingerall.org).
21
22 All you need to do on Sablotron side is to run the configure script 
23 with --enable-javascript option. To use JS engine from Charlie
24 installation, type: ./configure  --enable-javascript --enable-perlconnect
25
26 If you have installed JS libraries into non-standard directories, you 
27 need to set (and export) CPLUS_INCLUDE_PATH/LIBRARY_PATH to point to
28 directories where the header files/lib files (e.g. libjs.so) can be found.
29
30 The default name for the linked library is 'js' (-ljs switch) - if you
31 need to override this value, you may set SABLOT_JSLIB environment
32 variable - the configure script uses -l$(SABLOT_JSLIB) in this case.
33
34
35 2. What is working
36 ----------------------------------------
37
38 Sablotron supports JavaScript (ECMA) scripting as described in XSTL WD
39 1.1. with few exceptions:
40
41 - DOM functions handling namespaces (with NS in their name) are not
42   supported (throw NOT_SUPPORTED exception)
43
44 - DOM model is read only (as supported, may be changed later)
45
46 - XSLTContext.stringValue is not supported
47
48 - Document.getElementsByTagName{NS} are not supported
49
50 - Element.getElementsByTagName{NS} are not supported
51
52 - DTD definition nodes are not supported
53
54
55 The following summarizes what IS supported:
56
57 - exslt:script element support
58
59 - XSLTContext object
60
61 - DOM2 acces to a processed document
62
63 - type mapping between XPath and JavaScript including the XSLT
64   external object support
65
66 - function-available() function
67
68 - element-available() function
69
70
71 3. Sample stylesheet
72 ----------------------------------------
73
74 <?xml version='1.0'?>
75 <xsl:stylesheet version='1.0'
76                 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
77                 xmlns:exslt='http://www.exslt.org/functions'
78                 xmlns:my='http://gingerall.org/sablot/myfunc'
79                 extension-element-prefixes='exslt'
80                 exclude-result-prefixes='my'>
81
82   <xsl:output method='xml' indent='yes'/>
83
84   <exslt:script language='javascript' implements-prefix='my'>
85   <![CDATA[
86     
87     function getNodeNames(nodeList)
88     {
89       ret = '';
90       for (i = 0; i < nodeList.length; i++)
91       {
92         ret += nodeList[i].nodeName + " ";
93       }
94       return ret;
95     }     
96
97   ]]>
98   </exslt:script>
99
100
101   <xsl:template match='/'>
102     <output>
103       <xsl:value-of select='my:getNodeNames(*)'/>
104     </output>
105   </xsl:template>
106
107 </xsl:stylesheet>