Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL Error: call to method increment requires an Object instance as fir

Status
Not open for further replies.

XSLTerror

Programmer
Dec 9, 2007
1
US
I have the following XSL file, and I am getting the following error
Instance method call to method increment requires an Object instance as first argument in xsl

Can anyone help me

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl=" xmlns:func=" extension-element-prefixes="func"
xmlns:my="my://own.uri">

<xsl:eek:utput method="xml" indent="yes" />

<!-- INDECES -->
<xsl:variable name="childIdx" select="0" /> <!-- child index -->
<func:script language="javascript" implements-prefix="my">
var count = 0;
function increment() {
count++;
return count;
}
</func:script>

<xsl:template match="template">
<!-- begin tree -->
<xsl:text disable-output-escaping="yes">
&lt;tree id="0"&gt;
</xsl:text>
<!-- template -->
<xsl:element name="item">
<xsl:variable name="childIdx" select="1+$childIdx"/> <!-- logic need to changed -->
<xsl:attribute name="text">template</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="my:increment()"/>
</xsl:attribute>
<xsl:attribute name="child">
<xsl:value-of select="$childIdx"/>
</xsl:attribute>

<!-- non editable command -->
<xsl:apply-templates select="nonEditableCommand" />

<!-- |editableCommand|module|autofillCommand -->
</xsl:element>

<!-- end tree -->
<xsl:text disable-output-escaping="yes">
&lt;/tree&gt;
</xsl:text>
</xsl:template>

<!-- This will apply rules to all Non Editable Commands-->
<xsl:template match="nonEditableCommand">
<xsl:element name="item">
<xsl:variable name="childIdx" select="1+$childIdx"/> <!-- logic need to changed -->
<xsl:attribute name="text">nonEditableCommand</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="my:increment()"/>
</xsl:attribute>
<xsl:attribute name="child">
<xsl:value-of select="$childIdx"/>
</xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>


Thanks
Mallik
 
[1] There isn't any implementation for the exslt func:script module. That means it is no where supported yet.

[2] If you want it badly, you can use ms extension which implements script support; and you run the transformation with msxsl utility. Like this.
[tt]
<xsl:stylesheet version="1.0"
xmlns:xsl=" [blue]xmlns:func="urn:schemas-microsoft-com:xslt"[/blue]
extension-element-prefixes="[red]my[/red]"
xmlns:my="my://own.uri">
[/tt]
[3] At certain places, you have noted "logic need to change": you sure need to change those before the test to go through with positive result.

[4] At two places, you have use xsl:text to make a "tree" tag, you don't need that, do you? Use simply this construction for the purpose.
[tt] <xsl:element name="tree">
<!-- etc etc -->
</xsl:element>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top