This method allows a view to be specified as a string of text. The string provided to this method as a parameter must contain a complete XML stylesheet document for use as a view within EditLive! for XML or the Visual Designer. The name parameter supplied with the view provides the name for view which is used to represent the view within the user interface.
Loading views via the addViewAsText method can reduce the load time of EditLive! for XML. This can be most easily achieved by using server-side scripting to load the view file from the server's file system into a scripting string variable which can then be used when instantiating EditLive! for XML.
When instantiating the Visual Designer this method should be used to add views to the Visual Designer.
A string specifying the name for the view being added.
In EditLive! for XML the name will be displayed on the tab representing the view on the interface.
In the Visual Designer the name will be displayed within the list of views available within the designer.
A string which contains the text of the view (XSL) document to be added to this instance of EditLive! for XML.
Example 16.4. addViewAsText Method Example Scripting
The following code would specify that Ephox EditLive! for XML is to include the given view, the view will be listed with the name View One.
JavaScript
editlive.addViewAsText("View One", "<xs:stylesheet xmlns:xs=...");The view string parameter for this method must be URL encoded. It is recommended that a server-side URL encoding function be used if available. The usage of the JavaScript escape function is not recommended as the JavaScript escape function does not fully comply with the URL encoding standard.
The XSL document in the examples above is incomplete, and will not function. It is given only as a example to aid understanding. The XSL document passed to EditLive! for XML via this method should not contain carriage return or new line characters.
The view string parameter for this method must be URL encoded. It is recommended that a server-side URL encoding function be used if available. The usage of the JavaScript escape function is not recommended as the JavaScript escape function does not fully comply with the URL encoding standard.
Loading views via the addViewAsText method can reduce the load time of EditLive! for XML. This can be most easily achieved by using server-side scripting to load the view file from the server's file system into a scripting string variable which can then be used when instantiating EditLive! for XML.
Copyright 2001-2005 Ephox Corporation. All Rights Reserved.