[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: "Juergen Hermann" <jhe@xxxxxxxxxxx>
Date: Fri, 09 Jun 2000 16:59:09 +0100
dom functions saxon
On Fri, 9 Jun 2000 14:44:37 +0100, Kay Michael wrote:

>I'm looking at changing Saxon to pass DOM NodeList and DocumentFragment
>objects to extension functions instead of the current proprietary Saxon
>classes: this would make Saxon extension functions compatible with Xalan.

I currently implement most of Saxon's extension functions for Xalan-C. :)
Should translate to Java more or less directly, in theory.

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)
{
    // Anzahl der Argumente prüfen
    if (argVec.size() < 2 || 3 < argVec.size())
    {
        executionContext.error("cops:range erwartet zwei oder drei Argumente!", context);

        // Obige Funktion KANN laut Doku eine Exception erzeugen, zur Sicherheit
        // liefern wird einen Rückgabewert
        return executionContext.getXObjectFactory().createNull();
    }

    // Argumente holen
    long from = long(floor(argVec[0]->num() + .5));
    long to   = long(floor(argVec[1]->num() + .5));
    long step = 1;
    if (argVec.size() >= 3) step = long(floor(argVec[2]->num() + .5));
    if (!step) step = 1;

    // Ergebnisliste anlegen und befüllen
    MutableNodeRefList result(executionContext.createMutableNodeRefList());
    for (long num = from; num <= to; num += step)
    {
        XalanText* numNode = context->getOwnerDocument()->createTextNode(strNum(num).c_str());
        result.addNode(static_cast<XalanNode*>(numNode));
    }

    return executionContext.getXObjectFactory().createNodeSet(result);
}

I hope you can grok it, even with the German comments. :)



Ciao, Jürgen

--
Jürgen Hermann (jhe@xxxxxxxxxxx)
WEB.DE AG, Amalienbadstr.41, D-76227 Karlsruhe
Tel.: 0721/94329-0, Fax: 0721/94329-22



 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.