download    Version 1.0 - Initial version

In this section we propose an extension based on Bean Scripting Framework allowing end-user to write rule behaviour using another formalism like BeanShell, Javascript, Ruby etc. ...

Using BSF

The following example shows possibilities available using BSF extension. In fact code can be written using different formalisms in the same transducer and such code can shared objects using BSF bean register and lookup mechanisms.


   <Transducer syntax='$(vodoo-stream.site)/bsf/bsf.xsp'>

    <Script language="javascript">
     // Javascript code ...
    </Script>

    <When>
      <Element>
        <Script type="beanshell">
          // Beanshell code ...
        </Script>
      </Element>      
    </When>

   <Transducer>
   

In the distribution significant examples show possibilities using BSF support. These examples can be found on the site-xsp directory. One (samples/url/url.xsp) provides a naive method to extract hyper references and another one (samples/expand/expand.xsp) provides a simple file expander using a file of substitutions.

Simple Example based on BSF

The following XSP transducer detects all tags with an attribute named href in all namespaces and display in such case a message reflecting the recognition and the extraction reporting in the standard output the value of the href.


  <Transducer syntax='$(vodoo-stream.site)/bsf/bsf.xsp'>
      <Input mime='xml'/>
  
      <!-- ######################################## -->
  
      <When> <!-- Any element with a required attribute named 'href' -->
  	<Element>
          <Attribute name='href' type='required'/>
          <Script language="beanshell">
  	    System.out.println("Found ["+CTX.getValueOf("href")+"]");
  	    CTX.parse();
          </Script>
        </Element>
      </When>
  
      <!-- Defaults ############################### -->
  
      <!-- Any elementReference -->
      <When>
  	<Element>
   	  <Parse/>
  	</Element>
      </When>
  
      <!-- Any text -->
      <When>
  	<Text/>
      </When>
  
  </Transducer>