Wrox Programmer Forums
|
BOOK: Professional Ajax ISBN: 978-0-471-77778-6
This is the forum to discuss the Wrox book Professional Ajax by Nicholas C. Zakas, Jeremy McPeak, Joe Fawcett; ISBN: 9780471777786
Important: For the new 2nd edition of this book, please post here instead: [url="http://p2p.wrox.com/forum.asp?FORUM_ID=307"]http://p2p.wrox.com/forum.asp?FORUM_ID=307[/url]
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Ajax ISBN: 978-0-471-77778-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 22nd, 2006, 08:27 AM
Vx Vx is offline
Registered User
 
Join Date: Mar 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT in IE: adding js object to a stylesheet

Hi,

Could somebody tell me is it possible to set a property for an object added to a stylesheet with addObject(obj, namespace) method depending on values calculated during the transformation? Or (which is more desired) to pass parameters to its method call?
What I am trying to do is to use this object as a class factory for objects which wrap functionality (event handlers) for html elements created as a result of transformation.
So I need something like
Code:
<xsl:variable name="path" select="@path" />    
<xsl:variable name="type" select="@type" />
<xsl:variable name="index" select="xslObj:add('{$type}','{$path}')" />
<a href="javascript:void(0);" onclick="doSomething({$index});">
    <xsl:value-of select="@name"/>
</a>
Joe, please help me, I know it's your area of responsibility ;).

 
Old August 22nd, 2006, 10:15 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I don't see why not, if your object has the requisite method and the parameters are of the expected type. Your syntax is wrong though, assuming xslObj is the namespace then it would be:
Code:
<xsl:variable name="index" select="xslObj:add($type, $path)" />

--

Joe (Microsoft MVP - XML)
 
Old August 22nd, 2006, 11:00 AM
Vx Vx is offline
Registered User
 
Join Date: Mar 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot,

After your confirmation I've overcome it eventually.
Yes, I tried it with correct syntax originally as well, but the problem was that I received the following structure
Code:
path = { 
    item, 
    length: 1, 
    _newEnum {...} 
}
as an argument of my object's method whereas I expected just a plain string will be passed as a parameter of xslObj:add() method in the following code:
Code:
xsl
...
<xsl:variable name="path" select="@path" /> 
<xsl:variable name="index" select="xslObj:add($path)" />
...
javascript
myObject.prototype.add = function(path) {
    ...
}
And only after your answer I guessed (better later than never) to enumerate an argument and got path[0] was my desired parameter and it is not a string but a full-fledged attribute node (path[0].nodeType == 2) from my transformed xml document.
So in xslObj:add($path) - $path is a nodelist. Should I have expected it this way considering my code above?

Thank you once again and excuse my terrible English.







Similar Threads
Thread Thread Starter Forum Replies Last Post
apply-template from included xslt stylesheet chobo XSLT 9 April 16th, 2008 05:25 PM
Looking for developers for a XSLT stylesheet david_n XSLT 0 February 27th, 2007 10:03 AM
2 XML Docs > 1 XSLT Stylesheet kwilliams XSLT 3 September 12th, 2005 11:22 AM
Multiple XML Docs/One XSLT Stylesheet kwilliams XSLT 5 August 4th, 2005 11:54 AM
Parsing an XSLT stylesheet failed .... :( Thebravehearth XML 0 October 12th, 2004 10:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.