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; ...
Get XSLT, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.