xsl-list
[Top] [All Lists]

Re: Using variables in extension elements

2005-02-02 12:52:06
Well my original question was out of ignorance of the existence of Saxon 8! The new features of xslt 2 and xpath 2 solved major problems and allows my project to stay neat. Tunneling parameters are cool! Solved a huge problem I was having converting for example the following mathml equation:

   <apply>
       <eq/>
       <apply>
           <csymbol type="vector">C</csymbol>
           <ci >t</ci>
       </apply>
      <apply>
           <divide/>
           <apply>
               <sum />
               <bvar>
                   <ci type="integer">i</ci>
               </bvar>
               <lowlimit>
                   <cn>0</cn>
               </lowlimit>
               <uplimit>
                   <ci type="integer">n</ci>
               </uplimit>
               <apply>
                   <times/>
                   <apply>
                       <selector/>
                       <ci>w</ci>
                       <ci>i</ci>
                   </apply>
                   <apply>
                       <selector/>
                       <ci type="vector">d</ci>
                       <ci>i</ci>
                   </apply>
                   <apply>
                       <csymbol>N</csymbol>
                       <ci type="integer">i</ci>
                       <ci type="integer">p</ci>
                       <apply>
                           <selector/>
                           <ci>knot</ci>
                           <ci type="integer">i</ci>
                       </apply>
                       <ci>t</ci>
                   </apply>
               </apply>
           </apply>
           <apply>
               <sum />
               <bvar>
                   <ci type="integer">i</ci>
               </bvar>
               <lowlimit>
                   <cn>0</cn>
               </lowlimit>
               <uplimit>
                   <ci>n</ci>
               </uplimit>
               <apply>
                   <times/>
                   <apply>
                       <selector/>
                       <ci>w</ci>
                       <ci>i</ci>
                   </apply>
                   <apply>
                       <csymbol>N</csymbol>
                       <ci type="integer">i</ci>
                       <ci>p</ci>
                       <apply>
                           <selector/>
                           <ci>knot</ci>
                           <ci type="integer">i</ci>
                       </apply>
                       <ci>t</ci>
                   </apply>
               </apply>
           </apply>
       </apply>
   </apply>

to compilable and runnable at runtime Java code:

   public javax.vecmath.GVector C(double t)
   {
javax.vecmath.GVector C=null; C=divide((new com.pombi.mathml.lang.OperatorAdapter(){ public javax.vecmath.GVector vectorSum(double t){
         javax.vecmath.GVector sum=new javax.vecmath.GVector(3);
         for(int i=0;i<=n;i++)
         {
sum.add(times(new Object[]{w[(int)i],d[(int)i],N(i, p, knot, t)}));
         }
               return sum;
}}).vectorSum(t),(new com.pombi.mathml.lang.OperatorAdapter(){ public double sum(double t){
               double sum=0.0;
               for(int i=0;i<n;i++)
               {
sum+=((w[(int)i]*N(i, p, knot, t))); }
               return sum;
               }}).sum(t));
       return C;
   }

Isn't that sweet?! I recommend anybody out there to go to Saxon (8.2) and work with xslt 2.0 and xpath 2.0. Whole new world instead of trying to write extensions on other processors! Where tunneling parameters came in incredibly handy is the reuse of the parameter list and arguments from the math:csymbol definition to the inner class built for the math:sum element. double t from C(double t) passed to double sum(double t) and then the arguments can go to the inner class all nice and neat!

-Roger

P.S. Thanks Michael Kay!

JBryant(_at_)s-s-t(_dot_)com wrote:

Curiousity question: is anyone extending toward xslt 2.0 and xpath 2.0?

Check out Saxon 8. It implements the current draft of XSLT 2 and XPATH 2.

Jay Bryant
Bryant Communication Services
(on contract at Synergistic Solution Technologies)

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>
  • Re: Using variables in extension elements, Roger I Martin PhD <=