[JavaScript][XSLT][XML] Render XML with XSLT -- a purely javascript way

引述WIKI的定義,
白話說XSLT就是一種模版,XML則是資料來源,
同一份XML經由不同的XSLT渲染(render)出來的樣貌也就不同。
這次的需求是,為了減輕後端負擔,將渲染的工作延遲到瀏覽器端進行,
使用到瀏覽器的原生介面,
這次只針對WebKit 與IE兩種系列做出這個跨瀏覽器的小工具。

"transform" 的參數除了XSLT 與XML文件之外,
還有一個object,
可以動態賦值給XSLT對應的參數(而XML中沒有對應節點)
這個object可能是url的GET參數,或者其他頁面輸入。

In short, XSLT is a style sheet that defines how XML as source data should be rendered.

With different XSLT applied to a single source data, output document could look totally different.

The aim of this function is to offload render task from backend, and delay to client's browser, which will utilise browser's native API, and currently supports only webkit and IE.

Besides XSLT and XML document, "transform" also takes a object to inject some runtime determined value into template, those matches definition in XSLT but not assigned in XML. The runtime determined value could be GET parameters or form inputs.



留言