![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
![]() |

|
| Knowledge Base Most common error and how to trouble shoot them off |
![]() |
|
simple xslt extension function
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Fixed Error!
Posts: 141
Location: Chennai
Join Date: Feb 2007
Rep Power: 2
IM:
|
Saxon gives me the following error for the simple xslt and xml source files listed below. What am I doing wrong? command line and error output: ------------------------------------- $ java net.sf.saxon.Transform -t -novw source.xml test.xslt Saxon 8.8J from Saxonica Java version 1.5.0_09 Stylesheet compilation time: 781 milliseconds Processing file:/c:/src/belxml/dev/source.xml Building tree for file:/c:/src/belxml/dev/source.xml using class net.sf.saxon.tinytree.TinyBuilder Tree built in 0 milliseconds Tree size: 46 nodes, 97 characters, 4 attributes Error on line 15 of file:/c:/src/belxml/dev/test.xslt: Cannot find a matching 1-argument function named {testing}exampleCall() Transformation failed: Run-time errors were reported test.xslt: ---------- <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="XSLT namespace" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:fubar="testing" extension-element-prefixes="fubar" > <msxsl:script implements-prefix="fubar" language="C#"> <![CDATA[ public string exampleCall( string str ){return str;} ]]> </msxsl:script> <xsl:template match="person"> <p><xsl:value-of select="fubar:exampleCall(@name)" /></p> </xsl:template> </xsl:stylesheet> source.xml: -------------- <?xml version="1.0"?> <people> <person born="1912" died="1954"> <name> <first_name>Alan</first_name> <last_name>Turing</last_name> </name> <profession>computer scientist</profession> <profession>mathematician</profession> <profession>cryptographer</profession> </person> <person born="1918" died="1988"> <name> <first_name>Richard</first_name> <middle_initial>P</middle_initial> <last_name>Feynman</last_name> </name> <profession>physicist</profession> <hobby>Playing the bongoes</hobby> </person> </people> |
|
|
|
|
|
|
|
|
#2 (permalink) |
|
Fixed Error!
Posts: 141
Location: Chennai
Join Date: Feb 2007
Rep Power: 2
IM:
|
(maybe that is not even called msxml, I am not sure) Invalid class string is what you get when you have this function in C# in msxml4 standalone in msxml6 the message would be: C# is not a scripting language :-) either move to the XSLTransform of the .net framework or use JScript in msxml4 The JScript variant would be <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="XSLT namespace" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:fubar="testing" extension-element-prefixes="fubar" exclude-result-prefixes="msxsl" > <xsl utput method="xml" indent="yes"/><msxsl:script implements-prefix="fubar" language="JScript"> <![CDATA[ function exampleCall( str ){return str;} ]]> </msxsl:script> <xsl:template match="/"> <ps> <xsl:apply-templates/> </ps> </xsl:template> <xsl:template match="person"> <p><xsl:value-of select="fubar:exampleCall(name/last_name)" /></p> </xsl:template> </xsl:stylesheet> note that I added a template to create a container element, otherwise your result is not wellformed I changed @name into name/last_name, since name is not an attribute and I excluded the msxsl namespace from propagating to the output |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|