O'Reilly logo

XSLT, 2nd Edition by Doug Tidwell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Saxon Java Version

The Saxon extension element is considerably more complicated than the Xalan version. We have to create a class that implements the net.sf.saxon.style.ExtensionElementFactory interface. That class is responsible for processing the attributes of the <SaxonPhotoAlbum> element, including processing any attribute value templates that are in the element. Here’s the short file that performs this step:

/*
 * PhotoAlbumElementFactory.java
 * Created on Nov 28, 2006 by Doug Tidwell
 */

package com.oreilly.xslt.saxon;

import net.sf.saxon.style.ExtensionElementFactory;

public class PhotoAlbumElementFactory
  implements ExtensionElementFactory
{
  public Class getExtensionClass(String elementName)
  {
    if (elementName.equals("SaxonPhotoAlbum"))
      return SaxonPhotoAlbum.class;
    return null;
  }
}

Notice that the code returns the class object for the SaxonPhotoAlbum class. Saxon uses that object to actually create a SaxonPhotoAlbum object that processes the element in the stylesheet:

/* * SaxonPhotoAlbum.java * Created on Nov 28, 2006 by Doug Tidwell */ package com.oreilly.xslt.saxon; import java.io.File; import net.sf.saxon.event.Receiver; import net.sf.saxon.event.ReceiverOptions; import net.sf.saxon.expr.Expression; import net.sf.saxon.expr.SimpleExpression; import net.sf.saxon.expr.XPathContext; import net.sf.saxon.instruct.Executable; import net.sf.saxon.om.NamePool; import net.sf.saxon.style.ExtensionInstruction; import net.sf.saxon.style.StandardNames; import net.sf.saxon.trans.XPathException; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required