Click to return to the XML (Extensible Markup Language) home page    
XMLDOMDocument onreadysta...     XMLDOMDocument ontransfor...     XMLDOMDocument Object    
Web Workshop  |  XML (Extensible Markup Language)

ontransformnode Event


Fires before each node in the style sheet is applied to each node in the XML source.

Syntax

boolVal = ontransformnode(nodeCode, nodeData)

Parameters

nodeCode
Indicates the current node in the style sheet.
nodeData
Indicates the current node in the XML source data.

Return Value

Returns true to indicate that transformation processing is to continue; returns false to indicate that transformation processing should stop.

Remarks

The event handler for this event can be explicitly set using the ontransformnode property.

This member is an extension of the W3C DOM.

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 style sheet.

<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>

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 that 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 ) {
   alert("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>

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.

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
XMLDOMDocument


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.