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

Populate an array -- extension functions in LotusXSL

Subject: Populate an array -- extension functions in LotusXSL
From: "Garriss Jr.,James P." <jgarriss@xxxxxxxxx>
Date: Tue, 12 Oct 1999 11:19:24 -0400
populate an array
I am trying to read in several values from an XML file and store them in an array using an extension function written in Javascript. Despite what appears to be rather simple code, I am getting an XPath error -- "XSL process was not successful". I'm using LotusXSL 0.18.1 with XML4J 2.0.15 and JDK 1.1.7B on an NT 4.0 server. I would appreciate any thoughts on why this isn't working or even better ideas for how to store values in an array.

[BTW, I realize using an xsl:variable element is a rather unorthodox method for calling a function, but I couldn't think of a better way of calling one that doesn't have a returned value. Ideas welcome.]

TIA,

***** input XML document *****

<?xml version="1.0" encoding="UTF-8"?>
<numbers>
	<number value="1"/>
	<number value="2"/>
	<number value="3"/>
	<number value="4"/>
	<number value="5"/>
</numbers>

***** XSL stylesheet *****

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
                xmlns:lxslt="http://xsl.lotus.com/"
                xmlns:extn1="http://dev.mitre.org/"
                extension-element-prefixes="extn1">

<xsl:output method="text" indent="no"/>
<xsl:strip-space elements="*"/>

<!-- root -->
<xsl:template match="/">
	<xsl:apply-templates select="*"/>
</xsl:template>

<!-- numbers -->
<xsl:template match="numbers">
	<xsl:for-each select="*[@value]">
		<xsl:variable name="value" select="@value"/>
		<xsl:variable name="foo1" select="extn1:fcnArray($value)"/>
		<!-- <xsl:value-of select="$foo1"/> -->
	</xsl:for-each>
</xsl:template>

<lxslt:component prefix="extn1" elements="" functions="fcnArray">
<lxslt:script lang="javascript">
<![CDATA[

	aryValue = new Array;		// holds values
	var intPosition = 0;		// counter

	// populate an array
	function fcnArray(intNewValue)
	{
		aryPosition[intPosition] = intNewValue;
		intPosition = intPosition + 1;
		return;
	}

]]>
</lxslt:script>
</lxslt:component>

</xsl:stylesheet>


James Garriss | The MITRE Corporation | jgarriss @ mitre.org



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.