This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: A very interesting feature of MSXML
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] A very interesting feature of MSXML
- From: "Hewko, Doug" <Doug dot Hewko at ccra-adrc dot gc dot ca>
- Date: Mon, 13 Aug 2001 07:37:31 -0400
- Cc: "'gutman at novosoft-us dot com'" <gutman at novosoft-us dot com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
In Cocoon2, I get "<result xmlns:x="urn:x"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"></result>"
-----Original Message-----
From: Alexander Gutman [mailto:gutman@novosoft-us.com]
Sent: August 11, 2001 8:58 AM
To: xsl-list@lists.mulberrytech.com
Subject: [xsl] A very interesting feature of MSXML
Hello, friends.
I have just discovered a very interesting feature of MSXML.
If we transform this:
<root>
<one/>
<two/>
<three/>
</root>
via this:
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:x="urn:x">
<msxsl:script language="JScript" implements-prefix="x">
var m = 'old';
function setMode(newMode){ m = newMode; return 'changed' }
function mode(){ return m }
</msxsl:script>
<xsl:template match="/root" priority="1">
<result>
<xsl:apply-templates select="*"/>
</result>
</xsl:template>
<xsl:template match="*[x:mode()='old']">
<xsl:copy>
<xsl:attribute name="mode">old</xsl:attribute>
</xsl:copy>
</xsl:template>
<xsl:template match="*[x:mode()='new']">
<xsl:copy>
<xsl:attribute name="mode">new</xsl:attribute>
</xsl:copy>
</xsl:template>
<xsl:template match="two" priority="1">
<two mode="{x:setMode('new')}"/>
</xsl:template>
</xsl:transform>
then we obtain:
<result>
<one mode="old"/>
<two mode="changed"/>
<three mode="new"/>
</result>
I did not believe it would work, but it works!
I am not sure that this behavior is standards-driven,
but it is very convenient.
--
Alexander E. Gutman
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list