setStartMode Method
Performs subsets of larger XSL Transformations (XSLT) by selecting the XSLT mode with which to start. This minimizes the amount of XSLT processing.
The default value of the start mode is the empty string, "".
Example
var xslt = new ActiveXObject("Msxml2.XSLTemplate.5.0"); var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.5.0"); var xslProc; xslDoc.async = false; xslDoc.load("sample2.xsl"); xslt.stylesheet = xslDoc; var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0"); xmlDoc.async = false; xmlDoc.load("books.xml"); xslProc = xslt.createProcessor(); xslProc.input = xmlDoc; xslProc.setStartMode("view"); xslProc.transform(); alert(xslProc.output);
File Name: Sample2.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:param name="param1"/> <xsl:template match="/"> Hello </xsl:template> <xsl:template match="/" mode="edit"> In Edit Mode </xsl:template> <xsl:template match="/" mode="view"> In View Mode </xsl:template> </xsl:stylesheet>
[Script]
Script Syntax
objXSLProcessor.setStartMode(mode, namespaceURI);
Parameters
- mode
- The desired mode as a string. It must be the base name part of the qualified name.
- namespaceURI (optional)
- The full namespace URI to fully qualify the start mode name.
[Visual Basic]
Visual Basic Syntax
objXSLProcessor.setStartMode(mode, namespaceURI)
Parameters
- mode
- The desired mode as a string. It must be the base name part of the qualified name.
- namespaceURI (optional)
- The full namespace URI to fully qualify the start mode name.
Example
Dim xslt As New Msxml2.XSLTemplate50 Dim xslDoc As New Msxml2.FreeThreadedDOMDocument50 Dim xmlDoc As New Msxml2.DOMDocument50 Dim xslProc As IXSLProcessor xslDoc.async = False xslDoc.Load "sample2.xsl" If (xmlDoc.parseError.errorCode <> 0) Then Dim myErr Set myErr = xmlDoc.parseError MsgBox("You have error " & myErr.reason) Else Set xslt.stylesheet = xslDoc xmlDoc.async = False xmlDoc.Load "books.xml" If (xmlDoc.parseError.errorCode <> 0) Then Dim myErr Set myErr = xmlDoc.parseError MsgBox("You have error " & myErr.reason) Else Set xslProc = xslt.createProcessor() xslProc.input = xmlDoc xslProc.setStartMode "view" xslProc.Transform MsgBox xslProc.output End If End If
File Name: Sample2.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:param name="param1"/> <xsl:template match="/"> Hello </xsl:template> <xsl:template match="/" mode="edit"> In Edit Mode </xsl:template> <xsl:template match="/" mode="view"> In View Mode </xsl:template> </xsl:stylesheet>
[C/C++]
C/C++ Syntax
HRESULT setStartMode(BSTR mode, BSTR namespaceURI);
Parameters
- mode [in]
- The desired mode as a string. It must be the base name part of the qualified name.
- namespaceURI [in, optional]
- The full namespace URI to fully qualify the start mode name.
C/C++ Return Values
- S_OK
- Success
- E_FAIL
- The value returned if the value of the
readyState
property isREADYSTATE_INTERACTIVE
. - E_INVALIDARG
- The value returned if the mode base name contains a colon character or is an invalid name.
Remarks
Using setStartMode
is essentially the same as an XSLT style sheet that starts with the following rule.
<xsl:template match="/"> <xsl:apply-templates select="*" mode="{mode}"/> </xsl:template>
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button in the upper-left corner of the page.
See Also
Applies to: IXSLProcessor
Other Resources
W3C Qualified Names section of the XSLT Version 1.0 W3C Recommendation | W3C Namespaces in XML Recommendation