Freigeben über


ontransformnode Property

 

Specifies the event handler for the ontransformnode event.

Important

Sample code used for demonstration purposes in this topic assumes a side-by-side installation of another previous version of MSXML. The use of "http://www.w3.org/TR/WD-xsl" to declare the older deprecated XSL namespace causes this requirement.

Script Syntax

oXMLDOMDocument.ontransformnode = funcMyEventHandler;  

Example

In this example, the XML data island named "target" contains the XML source data, and the XML data island named "ss" contains the XSL (XSL) style sheet.

<XMLROOT>
    <XML id="target">
        <PEOPLE>
            <PERSON name="Atkinson, Teresa"  />
    <PERSON name="Debroux, Steve" />
    <PERSON name="O'Hara, Robert" />
    <PERSON name="Porzuczek, Peter" />
        </PEOPLE>
    </XML>
    <XML id="ss">
      <xsl:template match="/" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
        <xsl:for-each select="/PEOPLE/PERSON/@name" >   
    <P><xsl:value-of /></P>
      </xsl:for-each>
      </xsl:template>
    </XML>
</XMLROOT>

This script contains the Verify function, which sets the ontransformnode property to the event handler, onxform(). The event handler is called before the transformation operation on each node, so given the sample data provided in the data islands, this sample calls the alert several times.

<SCRIPT LANGUAGE="javascript" FOR="window" EVENT="onload">
document.expando = false;
Verify();
</SCRIPT>
<Script LANGUAGE="javascript">
function onxform ( code, doc ) {
    WScript.Echo("Target document node being transformed:\n\n" + doc.xml +
       "\n\nStylesheet node used for the transform:\n\n" + code.xml);
   if (doc.value == "O'Hara, Robert") 
return false;  // stop processing
   else
return true;
}
function Verify() {
   target.ontransformnode = onxform;
   var sOut = target.XMLDocument.transformNode(ss.XMLDocument);
   div.innerHTML += sOut;
}
</Script>
<DIV id=div></DIV>
</BODY>
</HTML>

Note

The return value from the event handler indicates whether to continue processing. In this example, the event handler checks for a particular data value and returns the value "false" to stop transformation processing.

Visual Basic Syntax

oXMLDOMDocument.ontransformnode = funcMyEventHandler  

C/C++ Syntax

HRESULT put_ontransformnode(  
    VARIANT ontransformnodeSink);  

Parameters

ontransformnodeSink[in]
Name of the function that should be called when a transformation is about to be performed.

Remarks

The property is write-only. A transformation involves two trees: the XML source and the style sheet that is applied to it. The ontransformnode event fires before each node in the style sheet is applied to each node in the XML source.

The ontransformnode property provides a way for developers to specify an event handler to override the default handler.

This member is an extension of the World Wide Web Consortium (W3C) Document Object Model (DOM).

Versioning

Implemented in:

MSXML 3.0, MSXML 6.0

Applies to

IXMLDOMDocument-DOMDocument | transformNode Method

See Also

ontransformnode Event