This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Wanted: Extension functions using DOM interfaces
- To: <xsl-list at mulberrytech dot com>
- Subject: Re: Wanted: Extension functions using DOM interfaces
- From: "Michael Beddow" <gll6mb at smlc01 dot leeds dot ac dot uk>
- Date: Sat, 10 Jun 2000 00:27:03 +0100
- Reply-To: xsl-list at mulberrytech dot com
(Juergen Hermann):
> I hope you can grok it, even with the German comments. :)
Probably, but for anyone who can't, here's Juergen's code with
comments and output string translated:
=============================================================
This is "saxon:range" (plus a 3rd parameter, "step"):
XObject* cops_range(
XPathExecutionContext& executionContext,
const XalanDOMString& theNamespace,
const XalanDOMString& functionName,
XalanNode* context,
const XPathEnvSupport::XObjectArgVectorType& argVec)
{
// Check the number of arguments
if (argVec.size() < 2 || 3 < argVec.size())
{
executionContext.error("cops:range expects two or three
arguments!", context);
// According to docs, this function MAY throw an
exception
// To be on the safe side, we provide a return value
return
executionContext.getXObjectFactory().createNull();
}
// Fetch the arguments
long from =3D long(floor(argVec[0]->num() + .5));
long to =3D long(floor(argVec[1]->num() + .5));
long step =3D 1;
if (argVec.size() >=3D 3) step =3D
long(floor(argVec[2]->num() + .5)=
);
if (!step) step =3D 1;
// Create and populate results list
MutableNodeRefList
result(executionContext.createMutableNodeRefList(=
));
for (long num =3D from; num <=3D to; num +=3D step)
{
XalanText* numNode =3D
context->getOwnerDocument()->createTextNo=
de(strNum(num).c_str());
result.addNode(static_cast<XalanNode*>(numNode));
}
return
executionContext.getXObjectFactory().createNodeSet(result);
}
================================================================
===
Michael Beddow
University of Leeds UK
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list