Processes this node and its children using the supplied XSL style sheet, and returns the resulting transformation.
Visual Basic Syntax
oXMLDOMNode.transformNodeToObject(stylesheet, outputObject)
C/C++ Syntax
HRESULT transformNodeToObject(
IXMLDOMNode *stylesheet,
VARIANT outputObject);
Parameters
stylesheet
[in]
Valid XML document or DOM node, which consists of XSL elements that direct the transformation of this node.
outputObject
[in]
Object that contains the product of the transformation of this XML document based on the XSL style sheet. If the variant represents the IXMLDOMDocument object, the document is built according to its properties, and its child nodes are replaced during this transformation process. If the variant contains an IStream interface, the XML transformation is sent to this stream.
C/C++ Return Values
S_OK
Value returned if successful.
E_INVALIDARG
Value returned if stylesheet or outputObject is null.
C/C++ Return Value
Returns S_OK if successful, or an error code otherwise.
Remarks
The stylesheet parameter must be either a DOM Document node, in which case the document is assumed to be an XSL style sheet, or a DOM node in the XSL stylesheet, in which case this node is treated as a stand-alone style sheet fragment.
The source node defines a context for the stylesheet to operate on, but navigation outside this scope is allowed. For instance, a stylesheet could use the ancestor or id methods to access other parts of the document.
This method supports both stand-alone and embedded style sheets, and additionally provides the ability to run a localized style sheet fragment against a particular source node.
For more information about XSL, see the XSL Reference and Using the XSL Processor.
Example
This example sets up the new IXMLDOMDocument object and puts it into a VARIANT before making the call to transformNodeToObject.
// p is the XML source that is to be transformed, pXSL is the style sheet
// Create an empty DOM document for the result.
// (error checking omitted for brevity)
hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument, (void**)&pDoc);
hr = pDoc->QueryInterface(IID_IDispatch, (void **)&pDisp);
vObject.vt = VT_DISPATCH; // the new object
vObject.pdispVal = pDisp;
hr = p->transformNodeToObject(pXSL, vObject); // transformation is
// present in pDoc