XopusCanvas.setViewParam
Description
This method can be used to set the value of parameters in the XSL of the canvas.
This method is available on the XopusCanvas objects, and is most easily accessed through:
var canvas = Editor.Canvas.getActiveCanvas();
canvas.setViewParam("name", value);
Parameters need to be declared in the stylesheet that is used by the canvas:
<xsl:param name="name" select="0"/>
It is also possible, since SDL Xopus 3.2.9, to use nodes as the values for parameters, and draw these params and the nodes contained in them in other parts of the document. SDL Xopus (SDL Xopus) versions before 3.2.9 did not handle the node correctly if the node was set using this method.
<xsl:param name="selectedNode" select="/doc/chapter[1]/section[1]"/>
…
<xsl:template name="toc">
<ol>
<xsl:for-each select="/doc/chapter/section">
<li>
<a href="#" onclick="Editor.Canvas.getActiveCanvas().setViewParam('selectedNode', node)">
<xsl:value-of select="title"/>
</a>
</li>
</xsl:for-each>
</ol>
</xsl:template>
…
<xsl:template name="currentlySelectedNode">
<div>
<xsl:apply-templates select="$selectedNode"/>
</div>
</xsl:template>
When working with large XML documents, using parameters to draw only parts of the document can be a good way to limit the amount of XHTML drawn in the editor, which is good for performance.
All stylesheets
Please note that this method will set this parameter in all the XSL stylesheets of the currently active view.
Syntax
XopusCanvas .setViewParam (name : String, value : Object|String)
Arguments
- name
-
String. The name of the parameter as declared in the XSL. - value
-
Object|String. The object or string to be set as the value of the param.