<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.1.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: JSLT javascript-based XSLT alternative</title>
	<link>http://www.rikarends.com/jslt-alternative-to-xslt/</link>
	<description>Ideas and code</description>
	<pubDate>Fri, 29 Aug 2008 03:30:31 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.1</generator>

	<item>
		<title>By: overthinkings &#187; Javeline Platform 1.0.1</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-3</link>
		<author>overthinkings &#187; Javeline Platform 1.0.1</author>
		<pubDate>Mon, 05 Mar 2007 00:00:51 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-3</guid>
					<description>[...] are many different transformation rules possible. You can specify a mask, use XSLT, JSLT or javascript methods to process the data from XML. For more information on this see the [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] are many different transformation rules possible. You can specify a mask, use XSLT, JSLT or javascript methods to process the data from XML. For more information on this see the [&#8230;]</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Ajax Girl</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-58</link>
		<author>Ajax Girl</author>
		<pubDate>Wed, 11 Apr 2007 12:22:13 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-58</guid>
					<description>[...] Arends has created JSLT, a pure JavaScript replacement for XSLT.  JSLT is a browser based templating language like XSLT, [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Arends has created JSLT, a pure JavaScript replacement for XSLT.  JSLT is a browser based templating language like XSLT, [&#8230;]</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: XSLT per JavaScript at WWWorker - Sascha A. Carlin</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-59</link>
		<author>XSLT per JavaScript at WWWorker - Sascha A. Carlin</author>
		<pubDate>Wed, 11 Apr 2007 13:43:07 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-59</guid>
					<description>[...] Rik Ardens hat eine auf den ersten Blick sehr brauchbare Implementierung von XSLT in Javascript &#8212; JSLT &#8212; veröffentlicht. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Rik Ardens hat eine auf den ersten Blick sehr brauchbare Implementierung von XSLT in Javascript &#8212; JSLT &#8212; veröffentlicht. [&#8230;]</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Denver</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-60</link>
		<author>Denver</author>
		<pubDate>Wed, 11 Apr 2007 16:49:21 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-60</guid>
					<description>I have admire your unselfishness in taking the time to make this web site.</description>
		<content:encoded><![CDATA[<p>I have admire your unselfishness in taking the time to make this web site.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Jack William Bell</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-61</link>
		<author>Jack William Bell</author>
		<pubDate>Wed, 11 Apr 2007 17:00:22 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-61</guid>
					<description>Some suggestions for additional shortcut characters:

. Eat whitespace before the template element

~ Eat whitespace after the template element

^ out=filter( template element ); where filter() is a standard function which calls an array of filter functions in array order and it is easy to add and remove functions from that array at runtime (Yes, I can easily implement filter without the shortcut character)

Question: Is there any plan to provide the same (or similar) convenience functions for navigating and querying JSON as for XML?

Another question: Why did you choose to use curly braces for outputting context node values? I prefer to use consistent bracketing practices, so I would have chosen double square brackets for that case or else provided yet another shortcut character.</description>
		<content:encoded><![CDATA[<p>Some suggestions for additional shortcut characters:</p>
<p>. Eat whitespace before the template element</p>
<p>~ Eat whitespace after the template element</p>
<p>^ out=filter( template element ); where filter() is a standard function which calls an array of filter functions in array order and it is easy to add and remove functions from that array at runtime (Yes, I can easily implement filter without the shortcut character)</p>
<p>Question: Is there any plan to provide the same (or similar) convenience functions for navigating and querying JSON as for XML?</p>
<p>Another question: Why did you choose to use curly braces for outputting context node values? I prefer to use consistent bracketing practices, so I would have chosen double square brackets for that case or else provided yet another shortcut character.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: admin</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-62</link>
		<author>admin</author>
		<pubDate>Wed, 11 Apr 2007 17:16:36 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-62</guid>
					<description>Hi Jack,

Thanks for your post. Let me answer your questions.
1. I will think about the shortcut characters for the template processing. Now it is a global setting to 'remove whitespace before template elements'. 
2. I dont quite get what you mean by filter.. the XSLT template/apply idea? That one is implemented already.
3. JSON sounds like a very easy one to support with JSLT. I will consider it for a next version. Thanks for the idea.
4. I adopted the XSLT curly braces for inline xpaths. You can also use code brackets like so: [%$'xpath].</description>
		<content:encoded><![CDATA[<p>Hi Jack,</p>
<p>Thanks for your post. Let me answer your questions.<br />
1. I will think about the shortcut characters for the template processing. Now it is a global setting to &#8216;remove whitespace before template elements&#8217;.<br />
2. I dont quite get what you mean by filter.. the XSLT template/apply idea? That one is implemented already.<br />
3. JSON sounds like a very easy one to support with JSLT. I will consider it for a next version. Thanks for the idea.<br />
4. I adopted the XSLT curly braces for inline xpaths. You can also use code brackets like so: [%$&#8217;xpath].</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Adam van den Hoven</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-63</link>
		<author>Adam van den Hoven</author>
		<pubDate>Wed, 11 Apr 2007 17:19:43 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-63</guid>
					<description>Rik, 

I applaud your skill but I think that you totally missed the boat with XSLT. Personally, I find XSL far simpler to write than almost any other programming language that I've come accross. If you treat it as a procedural or OO language then you're going to get stuck, but if you treat it as a functional language (which folks much smarter than I have proven) then you start to see the great benefits it has. 

for example you used some horribly inefficient XSLT in your examples, in some cases doing things in exactly the way that the XSLT "cool kids" say you shouldn't do. For example:


 
  
   Item of type A: 
  
  
   Item of type B: 
   
 



should be 



...


Item of type A: 


Item of type B: 


There are things that you could't easily do with your JSLT that XSL does trivially. For example, if I wanted to sort that list of items by their price attributes, all I need to do is use sort:


 


Not to mention that if you simply do XSLT the "right" way (using templates well), you get modular, resuable code for free. With JavaScript in general, this is a LOT of work.</description>
		<content:encoded><![CDATA[<p>Rik, </p>
<p>I applaud your skill but I think that you totally missed the boat with XSLT. Personally, I find XSL far simpler to write than almost any other programming language that I&#8217;ve come accross. If you treat it as a procedural or OO language then you&#8217;re going to get stuck, but if you treat it as a functional language (which folks much smarter than I have proven) then you start to see the great benefits it has. </p>
<p>for example you used some horribly inefficient XSLT in your examples, in some cases doing things in exactly the way that the XSLT &#8220;cool kids&#8221; say you shouldn&#8217;t do. For example:</p>
<p>   Item of type A: </p>
<p>   Item of type B: </p>
<p>should be </p>
<p>&#8230;</p>
<p>Item of type A: </p>
<p>Item of type B: </p>
<p>There are things that you could&#8217;t easily do with your JSLT that XSL does trivially. For example, if I wanted to sort that list of items by their price attributes, all I need to do is use sort:</p>
<p>Not to mention that if you simply do XSLT the &#8220;right&#8221; way (using templates well), you get modular, resuable code for free. With JavaScript in general, this is a LOT of work.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: admin</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-64</link>
		<author>admin</author>
		<pubDate>Wed, 11 Apr 2007 18:03:56 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-64</guid>
					<description>Hi Adam,

I agree that my if a/b example is poorely chosen as it is begging for your remark that i have misunderstood XSLT. It is also a bad example. I have removed it from the article, and will replace it with something that shows the benefit of JSLT better. However if you want to go the recursive/functional approach, you can just do that with JSLT with the template and apply functionality. Also, the sort functionality from XSLT is trivial to implement in JSLT, although i must confess i have not yet needed it myself so i haven't added it to JSLT. 
From a proof point of view, functional programming is very 'clean' and predictable. However from an every day life problem solving point it can become very annoying and often requires to bend problems that are of an iterative/branching nature into a recursive kludge.
This imho really limits the maintainability of many of the clever XSLT solutions as they are often more of an egotrip in (forced) overapplying recursion than actually solving a computing problem in the simplest possible way.
As for modularity, JS is extremely modular. Of course, it is less naturally modular than a (semi)functional language like XSLT (truly functional languages don't have variable assignments) but that is a matter of finding the proper modularization.
As far as the template/sort structure goes. I often have a problem with XSLT binding its output order to the input order by the application of a template, and then to define a specific order to that processing to resort to sorting. This makes the actual flow through your template code very hard to see, and making little exceptions to the template flow a nightmare. With JSLT i can just pick wether i want implicit flow or explicit flow without much syntactic overhead.</description>
		<content:encoded><![CDATA[<p>Hi Adam,</p>
<p>I agree that my if a/b example is poorely chosen as it is begging for your remark that i have misunderstood XSLT. It is also a bad example. I have removed it from the article, and will replace it with something that shows the benefit of JSLT better. However if you want to go the recursive/functional approach, you can just do that with JSLT with the template and apply functionality. Also, the sort functionality from XSLT is trivial to implement in JSLT, although i must confess i have not yet needed it myself so i haven&#8217;t added it to JSLT.<br />
From a proof point of view, functional programming is very &#8216;clean&#8217; and predictable. However from an every day life problem solving point it can become very annoying and often requires to bend problems that are of an iterative/branching nature into a recursive kludge.<br />
This imho really limits the maintainability of many of the clever XSLT solutions as they are often more of an egotrip in (forced) overapplying recursion than actually solving a computing problem in the simplest possible way.<br />
As for modularity, JS is extremely modular. Of course, it is less naturally modular than a (semi)functional language like XSLT (truly functional languages don&#8217;t have variable assignments) but that is a matter of finding the proper modularization.<br />
As far as the template/sort structure goes. I often have a problem with XSLT binding its output order to the input order by the application of a template, and then to define a specific order to that processing to resort to sorting. This makes the actual flow through your template code very hard to see, and making little exceptions to the template flow a nightmare. With JSLT i can just pick wether i want implicit flow or explicit flow without much syntactic overhead.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: biker from bikaner</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-67</link>
		<author>biker from bikaner</author>
		<pubDate>Thu, 12 Apr 2007 10:30:43 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-67</guid>
					<description>Hi,
     I admire your effort but disagree with your trying to pass it on as a replacement for XSLT. Maybe your JSLT performs a few things that XSLT does that too with caveats. That doesn't make it a replacement for XSLT in any way. The 1.0 version of XSLT itself has so many features that any comparison of XSLT with anything else will be like comparing the Himalayas with the sierra nevada. Then there's XSLT 2.0 which even experts agree is quite a handful. I wish you good luck. Just don't pick on something without first knowing about it fully.

cheers,
prakash</description>
		<content:encoded><![CDATA[<p>Hi,<br />
     I admire your effort but disagree with your trying to pass it on as a replacement for XSLT. Maybe your JSLT performs a few things that XSLT does that too with caveats. That doesn&#8217;t make it a replacement for XSLT in any way. The 1.0 version of XSLT itself has so many features that any comparison of XSLT with anything else will be like comparing the Himalayas with the sierra nevada. Then there&#8217;s XSLT 2.0 which even experts agree is quite a handful. I wish you good luck. Just don&#8217;t pick on something without first knowing about it fully.</p>
<p>cheers,<br />
prakash</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: admin</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-68</link>
		<author>admin</author>
		<pubDate>Thu, 12 Apr 2007 11:27:05 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-68</guid>
					<description>Hi Prakash,

I could call it a 'practical' alternative for XSLT if you will. I have yet to encounter a client-side transform that is not easier to do in JSLT than XSLT, and i've done quite a few. As you claim XSLT is so much bigger than i have percieved, perhaps i have missed a whole class of XSLT usage i have never needed nor encountered. Please tell me what i have missed, or point to it. That way i will see what you mean. I know, for instance that i miss all the Xpath functions that return strings, because the browser DOM only allows xpaths that return nodes. However those functions are usuallly trivial to do in JS, and can be added easily. Please don't forget JSLT is not a language in itself, it is a way to use Javascript as a templating language, extended with a few helper functions for XML traversal that mimic XSLT semantics. 
For perspective, adding the XSLT template/apply structure to JSLT was just 10 lines of JS. I have a hard time believing you can do things in XSLT i cannot more easily do in Javascript especially with the power to extend the Javascript language to aid templating. However i'm sure there are cases with heavy namespace use, and processing huge XML files that JSLT will be less optimal (or functional) than XSLT. But as a client-side AJAX templating language it can be extremely useful and more maintainable.
I would love find and understand structures in XSLT that i have missed. Please tell me which ones, i'm very happy to be challenged on the usability scope of JSLT.</description>
		<content:encoded><![CDATA[<p>Hi Prakash,</p>
<p>I could call it a &#8216;practical&#8217; alternative for XSLT if you will. I have yet to encounter a client-side transform that is not easier to do in JSLT than XSLT, and i&#8217;ve done quite a few. As you claim XSLT is so much bigger than i have percieved, perhaps i have missed a whole class of XSLT usage i have never needed nor encountered. Please tell me what i have missed, or point to it. That way i will see what you mean. I know, for instance that i miss all the Xpath functions that return strings, because the browser DOM only allows xpaths that return nodes. However those functions are usuallly trivial to do in JS, and can be added easily. Please don&#8217;t forget JSLT is not a language in itself, it is a way to use Javascript as a templating language, extended with a few helper functions for XML traversal that mimic XSLT semantics.<br />
For perspective, adding the XSLT template/apply structure to JSLT was just 10 lines of JS. I have a hard time believing you can do things in XSLT i cannot more easily do in Javascript especially with the power to extend the Javascript language to aid templating. However i&#8217;m sure there are cases with heavy namespace use, and processing huge XML files that JSLT will be less optimal (or functional) than XSLT. But as a client-side AJAX templating language it can be extremely useful and more maintainable.<br />
I would love find and understand structures in XSLT that i have missed. Please tell me which ones, i&#8217;m very happy to be challenged on the usability scope of JSLT.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: biker from bikaner</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-69</link>
		<author>biker from bikaner</author>
		<pubDate>Fri, 13 Apr 2007 06:05:47 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-69</guid>
					<description>Hi,
    Iam glad you took my comment in the right sense.  I also understand that you have just begun whereas XSLT has been around for a long time. So it will probably be a while before JSLT will be a drop-in replacement for XSLT. Here's a few XSLT 1.0 features I have used:

1. Ability to load input files using the 'document' function
2. Import and include additional files having templates 
3. Assign default and explicit priorities to templates
4. call extension functions
5. Build temporary trees and call xpath on them though by using extensions
6. Loading the stylesheet dynamically with the XSL-stylesheet processing instruction 
7. Using catalogs to resolve dtds, schemas and entities
8. Generate another stylesheet as result
9. Transform to XML, HTML, XHTML and text. The docbook stylesheets support additional formats.
10. Accept stylesheet parameters
11. normalize white-space
12. exclude unused namespace prefixes
13. Perform lookup using keys
14. call templates by name
15. perform grouping although with considerable effort

This is just the XSLT part without involving XPath. Many may not be required for your JScript version. I too haven't checked your software so well. I will sometime so I get a better picture. Let me know if your software does any of the above.

cheers,
prakash</description>
		<content:encoded><![CDATA[<p>Hi,<br />
    Iam glad you took my comment in the right sense.  I also understand that you have just begun whereas XSLT has been around for a long time. So it will probably be a while before JSLT will be a drop-in replacement for XSLT. Here&#8217;s a few XSLT 1.0 features I have used:</p>
<p>1. Ability to load input files using the &#8216;document&#8217; function<br />
2. Import and include additional files having templates<br />
3. Assign default and explicit priorities to templates<br />
4. call extension functions<br />
5. Build temporary trees and call xpath on them though by using extensions<br />
6. Loading the stylesheet dynamically with the XSL-stylesheet processing instruction<br />
7. Using catalogs to resolve dtds, schemas and entities<br />
8. Generate another stylesheet as result<br />
9. Transform to XML, HTML, XHTML and text. The docbook stylesheets support additional formats.<br />
10. Accept stylesheet parameters<br />
11. normalize white-space<br />
12. exclude unused namespace prefixes<br />
13. Perform lookup using keys<br />
14. call templates by name<br />
15. perform grouping although with considerable effort</p>
<p>This is just the XSLT part without involving XPath. Many may not be required for your JScript version. I too haven&#8217;t checked your software so well. I will sometime so I get a better picture. Let me know if your software does any of the above.</p>
<p>cheers,<br />
prakash</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: admin</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-70</link>
		<author>admin</author>
		<pubDate>Fri, 13 Apr 2007 08:38:27 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-70</guid>
					<description>Hi Prakash,
I will try to do a short JSLT answer on all your XSLT features

1. Ability to load input files using the ‘document’ function
JSLT: Very easy to add. JSLT just works with a local XMLnode object 'n'. I already have a parse(""){} function in JSLT with "" being the XML string. I can extend that to load files as well. You are free to store the parsed document in a variable for reuse anywhere aswell. I am thinking of a feature so you can prepend/join the node variable somehow with an xpath like so: [%value(otherdoc,'xpath')]. In that case you can always flip documents and context nodes per xpath lookup.

2. Import and include additional files having templates. 
JSLT is just javascript. It can recusively call itself easy. If you make a JS function like: [%jslt("otherfile");] you can inline process other JSLT files. If you want to parse them you can do this:
[parse(jslt("otherfile")){] now do xpaths on the output of the other jslt [}] 

3. Assign default and explicit priorities to templates
I must admit i dont have a priority feature on my templates, but that can be easily added.

4. call extension functions
just add a JS function anywhere to your global object, or adapt the JSLT code and you can have as many extensions as you like.

5. Build temporary trees and call xpath on them though by using extensions
Temporary trees are easy. Like so:
[store('temptree'){] &#60;x&#62;&#60;otherxml&#62;blah&#60;/otherxml&#62;&#60;/x&#62;[}]
[parse(fetch('temptree')){] {otherxml/text()} [}]
You can also nest this type by using pack 
[parse(pack(){] 
   &#60;x&#62;&#60;otherxml&#62;blah&#60;/otherxml&#62;&#60;/x&#62; 
[}){]  
  Fetch generated:{otherxml/text()} 
[}]

6. Loading the stylesheet dynamically with the XSL-stylesheet processing instruction.
This is a feature of the xml parser / xml viewer so this will not be possible. However as you usually write software to process XML and not rely on the processing instruction, i never had a problem with this.

7. Using catalogs to resolve dtds, schemas and entities
I have to admit i never used this, or know what it really means.

8. Generate another stylesheet as result
JSLT can easily be used to create other JSLT. However because JSLT is far more dynamic than XSLT, the need to create other stylesheets is dramatically reduced.

9. Transform to XML, HTML, XHTML and text. The docbook stylesheets support additional formats.
JSLT outputs 'text'. You can output any text based format like XML/HTML/XHTML with this. Of course it will not create a 'tree' but text. This might be a bit slower, and you can break the resulting XML tree more easily with a typo as you cannot XML validate the template.

10. Accept stylesheet parameters
You can use any JS variable/parameter in your template.

11. normalize white-space
JSLT has currently 2 modes, remove whitespaces at start of line or dont, and always removes newlines and tabs. This might need some tweaking.

12. exclude unused namespace prefixes
Dont know  what you mean by that.

13. Perform lookup using keys
You can lookup anything. Xpaths are just strings so you can concat them like this: [value('X'+value('@id'))] (will do an xpath lookup on the X+id attribute)
Also you can use temporary JS arrays to easily store variables for future reference. Really handy for creating an index atop a transformed document.

14. call templates by name
You can load subtemplates, but you can also call templates by name, or make macros, or custom string transform functions. Anything you want.

15. perform grouping although with considerable effort
Grouping is really _really_ easy in JSLT. 

To summarise:

Cons:
I'd say JSLT lacks in DTD/Schema support, and does not output XML tree's directly but always text making it easier to break your output xml.
JSLT is a bit slower.

Pros:
JSLT is almost infinitely flexible in doing streams/reuse/loading data/using variables/storing temp data and creating extension functions. Imho :)

Thanks for your comments.</description>
		<content:encoded><![CDATA[<p>Hi Prakash,<br />
I will try to do a short JSLT answer on all your XSLT features</p>
<p>1. Ability to load input files using the ‘document’ function<br />
JSLT: Very easy to add. JSLT just works with a local XMLnode object &#8216;n&#8217;. I already have a parse(&#8221;"){} function in JSLT with &#8220;&#8221; being the XML string. I can extend that to load files as well. You are free to store the parsed document in a variable for reuse anywhere aswell. I am thinking of a feature so you can prepend/join the node variable somehow with an xpath like so: [%value(otherdoc,&#8217;xpath&#8217;)]. In that case you can always flip documents and context nodes per xpath lookup.</p>
<p>2. Import and include additional files having templates.<br />
JSLT is just javascript. It can recusively call itself easy. If you make a JS function like: [%jslt(&#8221;otherfile&#8221;);] you can inline process other JSLT files. If you want to parse them you can do this:<br />
[parse(jslt(&#8221;otherfile&#8221;)){] now do xpaths on the output of the other jslt [}] </p>
<p>3. Assign default and explicit priorities to templates<br />
I must admit i dont have a priority feature on my templates, but that can be easily added.</p>
<p>4. call extension functions<br />
just add a JS function anywhere to your global object, or adapt the JSLT code and you can have as many extensions as you like.</p>
<p>5. Build temporary trees and call xpath on them though by using extensions<br />
Temporary trees are easy. Like so:<br />
[store(&#8217;temptree&#8217;){] &lt;x&gt;&lt;otherxml&gt;blah&lt;/otherxml&gt;&lt;/x&gt;[}]<br />
[parse(fetch(&#8217;temptree&#8217;)){] {otherxml/text()} [}]<br />
You can also nest this type by using pack<br />
[parse(pack(){]<br />
   &lt;x&gt;&lt;otherxml&gt;blah&lt;/otherxml&gt;&lt;/x&gt;<br />
[}){]<br />
  Fetch generated:{otherxml/text()}<br />
[}]</p>
<p>6. Loading the stylesheet dynamically with the XSL-stylesheet processing instruction.<br />
This is a feature of the xml parser / xml viewer so this will not be possible. However as you usually write software to process XML and not rely on the processing instruction, i never had a problem with this.</p>
<p>7. Using catalogs to resolve dtds, schemas and entities<br />
I have to admit i never used this, or know what it really means.</p>
<p>8. Generate another stylesheet as result<br />
JSLT can easily be used to create other JSLT. However because JSLT is far more dynamic than XSLT, the need to create other stylesheets is dramatically reduced.</p>
<p>9. Transform to XML, HTML, XHTML and text. The docbook stylesheets support additional formats.<br />
JSLT outputs &#8216;text&#8217;. You can output any text based format like XML/HTML/XHTML with this. Of course it will not create a &#8216;tree&#8217; but text. This might be a bit slower, and you can break the resulting XML tree more easily with a typo as you cannot XML validate the template.</p>
<p>10. Accept stylesheet parameters<br />
You can use any JS variable/parameter in your template.</p>
<p>11. normalize white-space<br />
JSLT has currently 2 modes, remove whitespaces at start of line or dont, and always removes newlines and tabs. This might need some tweaking.</p>
<p>12. exclude unused namespace prefixes<br />
Dont know  what you mean by that.</p>
<p>13. Perform lookup using keys<br />
You can lookup anything. Xpaths are just strings so you can concat them like this: [value(&#8217;X'+value(&#8217;@id&#8217;))] (will do an xpath lookup on the X+id attribute)<br />
Also you can use temporary JS arrays to easily store variables for future reference. Really handy for creating an index atop a transformed document.</p>
<p>14. call templates by name<br />
You can load subtemplates, but you can also call templates by name, or make macros, or custom string transform functions. Anything you want.</p>
<p>15. perform grouping although with considerable effort<br />
Grouping is really _really_ easy in JSLT. </p>
<p>To summarise:</p>
<p>Cons:<br />
I&#8217;d say JSLT lacks in DTD/Schema support, and does not output XML tree&#8217;s directly but always text making it easier to break your output xml.<br />
JSLT is a bit slower.</p>
<p>Pros:<br />
JSLT is almost infinitely flexible in doing streams/reuse/loading data/using variables/storing temp data and creating extension functions. Imho <img src='http://www.rikarends.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Thanks for your comments.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: biker from bikaner</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-72</link>
		<author>biker from bikaner</author>
		<pubDate>Fri, 13 Apr 2007 14:11:32 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-72</guid>
					<description>Hi Rik,
  The below code is pretty unreadable. Have you thought of placing them in js files.

e.g:
[store(’temptree’){] blah[}]
[parse(fetch(’temptree’)){] {otherxml/text()} [}]
You can also nest this type by using pack
[parse(pack(){]
blah
[}){]
Fetch generated:{otherxml/text()}
[}]

Another important feature strikes me.You say JSLT outputs text and you also have templates in JSLT. Does this mean you output tags instead of nodes. i.e is the following possible:

enter template A:

 &lt;!-- start tag of new node --&gt;
&lt;!-- no end tag here --&gt;

exit template A:

enter template B:

&lt;!-- end tag here. i.e not inside the same template as start tag --&gt;



exit template B:

If so, this is bad. XSLT doesn't output tags. It builds a tree in memory and serializes them. Also, you cannot output a '</description>
		<content:encoded><![CDATA[<p>Hi Rik,<br />
  The below code is pretty unreadable. Have you thought of placing them in js files.</p>
<p>e.g:<br />
[store(’temptree’){] blah[}]<br />
[parse(fetch(’temptree’)){] {otherxml/text()} [}]<br />
You can also nest this type by using pack<br />
[parse(pack(){]<br />
blah<br />
[}){]<br />
Fetch generated:{otherxml/text()}<br />
[}]</p>
<p>Another important feature strikes me.You say JSLT outputs text and you also have templates in JSLT. Does this mean you output tags instead of nodes. i.e is the following possible:</p>
<p>enter template A:</p>
<p> <!-- start tag of new node --><br />
<!-- no end tag here --></p>
<p>exit template A:</p>
<p>enter template B:</p>
<p><!-- end tag here. i.e not inside the same template as start tag --></p>
<p>exit template B:</p>
<p>If so, this is bad. XSLT doesn&#8217;t output tags. It builds a tree in memory and serializes them. Also, you cannot output a &#8216;</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: admin</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-73</link>
		<author>admin</author>
		<pubDate>Fri, 13 Apr 2007 15:01:53 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-73</guid>
					<description>Hi Prakash,

JSLT outputs 'tags' instead of nodes. It is a text-templating language. However, it could be extend to output tags. This will probably be a lot slower (DOM api from JS is really not fast), but that method will prevent missing tag errors. Sofar i have not run into issues with forgetting a tag. Just check the output of your template in an XML parser (as always happens when generating XML) to solve the problem.

On the unreadability part, i agree that it requires some getting used to reading JSLT. However, so does XSLT. I personally find large XSLT documents very hard to read, much harder than code. Especially if they have functionality encoded in recursive logic (that should be a loop or a temporary array). I guess its just something to get used to with JSLT.</description>
		<content:encoded><![CDATA[<p>Hi Prakash,</p>
<p>JSLT outputs &#8216;tags&#8217; instead of nodes. It is a text-templating language. However, it could be extend to output tags. This will probably be a lot slower (DOM api from JS is really not fast), but that method will prevent missing tag errors. Sofar i have not run into issues with forgetting a tag. Just check the output of your template in an XML parser (as always happens when generating XML) to solve the problem.</p>
<p>On the unreadability part, i agree that it requires some getting used to reading JSLT. However, so does XSLT. I personally find large XSLT documents very hard to read, much harder than code. Especially if they have functionality encoded in recursive logic (that should be a loop or a temporary array). I guess its just something to get used to with JSLT.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: All in a days work&#8230;</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-76</link>
		<author>All in a days work&#8230;</author>
		<pubDate>Sat, 14 Apr 2007 01:46:07 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-76</guid>
					<description>[...] JSLT - a JavaScript replacement for XSLT Instead of XML, it uses Javascript with a few extensions. Transform XML with it or just template with JavaScript variables. The JSLT processor parses the template using a recursive tokenizing parser and generates javascript code for fast dynamic (re-)exec (tags: XSLT JavaScript) [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] JSLT - a JavaScript replacement for XSLT Instead of XML, it uses Javascript with a few extensions. Transform XML with it or just template with JavaScript variables. The JSLT processor parses the template using a recursive tokenizing parser and generates javascript code for fast dynamic (re-)exec (tags: XSLT JavaScript) [&#8230;]</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: biker from bikaner</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-77</link>
		<author>biker from bikaner</author>
		<pubDate>Mon, 16 Apr 2007 07:27:24 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-77</guid>
					<description>Hi,
   Iam a victim of my own comment of outputting the tag character. The forum software ignored the stuff I had inside tags. What I meant to write was:
      
 is the following possible:

enter template A:

&#60;new_tag&#62;

exit template A:

enter template B:

&#60;/new_tag&#62;

exit template B:</description>
		<content:encoded><![CDATA[<p>Hi,<br />
   Iam a victim of my own comment of outputting the tag character. The forum software ignored the stuff I had inside tags. What I meant to write was:</p>
<p> is the following possible:</p>
<p>enter template A:</p>
<p>&lt;new_tag&gt;</p>
<p>exit template A:</p>
<p>enter template B:</p>
<p>&lt;/new_tag&gt;</p>
<p>exit template B:</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Matt K.</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-80</link>
		<author>Matt K.</author>
		<pubDate>Tue, 17 Apr 2007 06:44:51 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-80</guid>
					<description>I wish there was a sortby function.
Like
[*'re' sortby('date'){]

[}]

I don't know if this is possible but it would be mighty useful.

Thanks,
Matt k.</description>
		<content:encoded><![CDATA[<p>I wish there was a sortby function.<br />
Like<br />
[*&#8217;re&#8217; sortby(&#8217;date&#8217;){]</p>
<p>[}]</p>
<p>I don&#8217;t know if this is possible but it would be mighty useful.</p>
<p>Thanks,<br />
Matt k.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: admin</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-81</link>
		<author>admin</author>
		<pubDate>Tue, 17 Apr 2007 09:07:43 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-81</guid>
					<description>Hi Matt,

I have added a sort function per your request. Please check the live example/ blog article for updates on sort.

Your example looks like this now:
[sort('re','date',sort_date){]
 
[}]

Please be aware the sort xpath is relative to the foreach xpath and is executed on each item in the foreachset to obtain the sorting set.
Also, the core sorting algo works on 'stringsort' the function you pass in essentially converts the context node (date in this case) to a string
that can be properly sorted. the sort_date function converts a date to a 0 padded integer for example to apply stringsort.
</description>
		<content:encoded><![CDATA[<p>Hi Matt,</p>
<p>I have added a sort function per your request. Please check the live example/ blog article for updates on sort.</p>
<p>Your example looks like this now:<br />
[sort(&#8217;re&#8217;,'date&#8217;,sort_date){]</p>
<p>[}]</p>
<p>Please be aware the sort xpath is relative to the foreach xpath and is executed on each item in the foreachset to obtain the sorting set.<br />
Also, the core sorting algo works on &#8217;stringsort&#8217; the function you pass in essentially converts the context node (date in this case) to a string<br />
that can be properly sorted. the sort_date function converts a date to a 0 padded integer for example to apply stringsort.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: David Levy (( Creativity Matters &#187; Blog Archive &#187; JSLT : du XSLT en pur Javascript</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-82</link>
		<author>David Levy (( Creativity Matters &#187; Blog Archive &#187; JSLT : du XSLT en pur Javascript</author>
		<pubDate>Tue, 17 Apr 2007 09:39:07 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-82</guid>
					<description>[...] nouvelle librairie JSLT aussi exotique qu&#8217;utile remarquee par [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] nouvelle librairie JSLT aussi exotique qu&#8217;utile remarquee par [&#8230;]</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Tim Weaver</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-83</link>
		<author>Tim Weaver</author>
		<pubDate>Wed, 18 Apr 2007 01:20:07 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-83</guid>
					<description>&lt;strong&gt;XSLT is Hard so Try JSLT Instead...&lt;/strong&gt;

When I first read this post on the Ajaxian my very first (somewhat unkind) thought was OMG do we really...</description>
		<content:encoded><![CDATA[<p><strong>XSLT is Hard so Try JSLT Instead&#8230;</strong></p>
<p>When I first read this post on the Ajaxian my very first (somewhat unkind) thought was OMG do we really&#8230;</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Fatih Hayrioğlu&#8217;nun not defteri &#187; 19 Nisan 2007 Web&#8217;den seçme haberler</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-84</link>
		<author>Fatih Hayrioğlu&#8217;nun not defteri &#187; 19 Nisan 2007 Web&#8217;den seçme haberler</author>
		<pubDate>Thu, 19 Apr 2007 08:50:29 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-84</guid>
					<description>[...] XSLT&#8217;e javascript alternatifi. JSLT. Link [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] XSLT&#8217;e javascript alternatifi. JSLT. Link [&#8230;]</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Buy fioricet online.</title>
		<link>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-558</link>
		<author>Buy fioricet online.</author>
		<pubDate>Sat, 03 Nov 2007 00:03:35 +0000</pubDate>
		<guid>http://www.rikarends.com/jslt-alternative-to-xslt/#comment-558</guid>
					<description>&lt;strong&gt;Buy fioricet online that ships to missouri....&lt;/strong&gt;

Buy fioricet online. Buy fioricet online that ships to missouri. Buy fioricet online without a prescription....</description>
		<content:encoded><![CDATA[<p><strong>Buy fioricet online that ships to missouri&#8230;.</strong></p>
<p>Buy fioricet online. Buy fioricet online that ships to missouri. Buy fioricet online without a prescription&#8230;.</p>
]]></content:encoded>
				</item>
</channel>
</rss>
