[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Wanted: Extension functions using DOM interfaces

Subject: Re: Wanted: Extension functions using DOM interfaces
From: "Michael Beddow" <gll6mb@xxxxxxxxxxxxxxxxxx>
Date: Sat, 10 Jun 2000 00:27:03 +0100
3d dom free
(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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.