java - Camel - Error with JAXPSAXProcessorInvoker when function is added to xsl -


i have following stylesheet , xml:

students.xml

<?xml version="1.0" encoding="utf-8"?> <class>    <student rollno="393">       <firstname>dinkar</firstname>       <lastname>kad</lastname>       <nickname>dinkar</nickname>       <marks>85</marks>    </student>    <student rollno="493">       <firstname>vaneet</firstname>       <lastname>gupta</lastname>       <nickname>vinni</nickname>       <marks>95</marks>    </student>    <student rollno="593">       <firstname>jasvir</firstname>       <lastname>singh</lastname>       <nickname>jazz</nickname>       <marks>90</marks>    </student> </class> 

students.xsl

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:func="http://test"     version="2.0">     <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" xalan:indent-amount="4" xmlns:xalan="http://xml.apache.org/xalan"/>      <xsl:template match="*"><!-- matches node -->         <xsl:copy><!-- copies current node , namespace nodes,not child or attribute nodes -->             <xsl:apply-templates select="student" /><!-- applies template students elements -->         </xsl:copy>     </xsl:template>     <xsl:function name="func:marktograde">        <xsl:param name="markarg"/>        <xsl:choose>         <xsl:when test="$markarg &gt; 90 ">             <xsl:text>a</xsl:text>         </xsl:when>          <xsl:when test="$markarg &lt; 90 , $markarg &gt; 80">             <xsl:text>b</xsl:text>         </xsl:when>         <xsl:otherwise>              <xsl:text>c</xsl:text>         </xsl:otherwise>        </xsl:choose>     </xsl:function>       <xsl:template match="student">         <xsl:element name="person"><!-- renames element person -->             <xsl:attribute name="id-num"><!--  applies attribute new element called id-num -->                 <xsl:value-of select="@rollno" /><!-- copies value of student elements rollno attribute -->             </xsl:attribute>             <xsl:apply-templates select="lastname" /><!-- applies template lastname child nodes -->             <xsl:apply-templates select="marks" /><!-- applies template marks child nodes -->         </xsl:element>     </xsl:template>      <xsl:template match="lastname">         <xsl:element name="student-surname">             <xsl:attribute name="nick-name">                  <xsl:value-of select="../nickname" /><!-- moves level in xml tree , copies value nickname element -->             </xsl:attribute>             <xsl:value-of select="." /><!-- copies text value of current node -->         </xsl:element>     </xsl:template>      <xsl:template match="marks">         <xsl:element name="grade">             <xsl:value-of select="func:marktograde(text())" />         </xsl:element>     </xsl:template> </xsl:stylesheet> 

when try run via camel:

samplecamelrouter.java

@component public class samplecamelrouter extends routebuilder {      /* (non-javadoc)      * @see org.apache.camel.builder.routebuilder#configure()      */     @override     public void configure() throws exception {         // todo auto-generated method stub         from("file:src/main/resources/input/?filename=students.xml&noop=true")             .to("xslt:./transforms/students.xsl")             .to("file:target/messages/?filename=studentsout.xml");     } } 

i in ide console:

10:57:43,347 error [main] jaxpsaxprocessorinvoker  - first argument non-static java function 'marktograde' not valid object reference. 10:57:43,349 error [main] jaxpsaxprocessorinvoker  - first argument non-static java function 'marktograde' not valid object reference. javax.xml.transform.transformerconfigurationexception: first argument non-static java function 'marktograde' not valid object reference.     @ com.sun.org.apache.xalan.internal.xsltc.trax.transformerfactoryimpl.newtemplates(transformerfactoryimpl.java:1020)     @ com.sun.org.apache.xalan.internal.xsltc.trax.transformerfactoryimpl.newtransformer(transformerfactoryimpl.java:791)     @ com.sun.org.apache.xalan.internal.xsltc.trax.transformerfactoryimpl.newtransformerhandler(transformerfactoryimpl.java:1099)     @ org.eclipse.wst.xsl.jaxp.debug.invoker.internal.jaxpsaxprocessorinvoker.addstylesheet(jaxpsaxprocessorinvoker.java:137)     @ org.eclipse.wst.xsl.jaxp.debug.invoker.internal.jaxpsaxprocessorinvoker.addstylesheet(jaxpsaxprocessorinvoker.java:128)     @ org.eclipse.wst.xsl.jaxp.debug.invoker.pipelinedefinition.addstylesheet(pipelinedefinition.java:161)     @ org.eclipse.wst.xsl.jaxp.debug.invoker.pipelinedefinition.configure(pipelinedefinition.java:152)     @ org.eclipse.wst.xsl.jaxp.debug.invoker.internal.main.main(main.java:72) 10:57:43,354 fatal [main] main  - error stylesheet: file:/data/userdata/workspace/fnol/camel-test/src/main/resources/transforms/students.xsl org.eclipse.wst.xsl.jaxp.debug.invoker.internal.configurationexception: error stylesheet: file:/data/userdata/workspace/fnol/camel-test/src/main/resources/transforms/students.xsl     @ org.eclipse.wst.xsl.jaxp.debug.invoker.pipelinedefinition.addstylesheet(pipelinedefinition.java:163)     @ org.eclipse.wst.xsl.jaxp.debug.invoker.pipelinedefinition.configure(pipelinedefinition.java:152)     @ org.eclipse.wst.xsl.jaxp.debug.invoker.internal.main.main(main.java:72) 

i've tried xsl in few online tools support xsl v2, , works fine. whenever try above, keep getting errors despite xsl remaining same between ide , xsl test tools. i'm using camel spring boot starter, version 2.17.3 , version 2 xsl. i've checked few similar questions answered none seem apply use case, there i've left out of xsl thats causing this?


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -