---------- Forwarded message ----------
From: sky Chen <sky.freeprisoner@gmail.com>
Date: Thu, Jan 23, 2014 at 6:12 PM
Subject: Re: [saxon] Saxon extension instruction tutorial?
To: Michael Kay <mike@saxonica.com>

Thanks for reply. 

I'm replacing Xalan with Saxon, so there are extension instructions written for Xalan that need to be rewritten. I think it would be better if I rewrite Xalan extension elements into Saxon extension functions, however, I want to give extension element a try before making the choice. Right now I have a problem with extension element. I tried to write a simple extension element, but it failed to run with "XTDE 1450: Unknown extension instruction". Here is what my code looks like:

    ProfessionalConfiguration config = new ProfessionalConfiguration();
  config.setExtensionElementNamespace("degx", "DegElementFactory");

    if(localname.equals("value-of")) return DegxValueOf.class;

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:degx="http://DegElementFactory"  extension-element-prefixes="degx">
         <degx:value-of select="alpha 1"/>
I run Config.class first, and then running sf.net.saxon.Transform, I got the error above. My guess is I configured extension element namespace the wrong way. I have Saxon PE with evaluate license install correctly, because I got message about expired days after running Transform.

On Tue, Jan 21, 2014 at 7:47 PM, Michael Kay <mike@saxonica.com> wrote:
You're right, implementing extension instructions is not easy. That's partly because the APIs are quite complex, partly because the documentation is poor, and partly because the code that would help you understand it is not open source. The underlying reason for this is that not many people have attempted to do this, so there has been little feedback that would lead to improvement over the years.

I would encourage you to ask yourself seriously whether this is something you really want to do badly enough to cope with the difficulties.

The documentation extract you cite appears to be out of date. The "Callable" interface was a relatively recent addition, and the documentation has not caught up. Implementing the call() method is enough.

Michael Kay

On 21 Jan 2014, at 08:16, sky Chen <sky.freeprisoner@gmail.com> wrote:

I just start using Saxon. After go through some documentations, I still found it hard to write my own custom extension instruction. I have read "writing XSLT extension instructions", and the example provided in the package net.sf.saxon.option.sql. But I'm still a little confusing: the document says,

  A subclass of SimpleExpression should implement the methods getImplementationMethod() and getExpressionType(), and depending on the value returned by getImplementationMethod(), should implement one of the methods evaluateItem(), iterate(), or process().
However, there is only call() method implemented in the sql example. I'm new to XML/XSLT, hence find it hard to understand how to write my own extension elements.
Is there a tutorial of some kind which explains writing extension elements in more detail?(I have Google but found no luck, the best I can find is with older Saxon version that has different implementation). Or maybe I should go through some other XML/XSLT intermediate first?

Thanks in advance!!
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
saxon-help mailing list archived at http://saxon.markmail.org/