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

Re: XslTrasnformation - Index was outside the bounds o

Subject: Re: XslTrasnformation - Index was outside the bounds of the array
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Mon, 08 Jan 2007 12:08:59 +0100
Re:  XslTrasnformation - Index was outside the bounds o
Karl Stubsjoen wrote:
I am getting an Index was outside the bounds of the array error when I
apply the following template select:

Where do you get the IndexOutOfBoundsError? That is not an XSLT error, so it has to do something with your .NET code.



<xsl:apply-templates select="*[name() = $Fields_MappedForUpdate/Field]"/>


I do not get this error if I remove the /Field from above.  This feels
like a big nasty bug to me.

I assume you do something with the returned results, which are apparently not of the form you expect (?)


Can you paste in a snippet of your C#/VB that raises this exception? What is the source/xslt context of the xslt statement above?


$Fields_MappedForUpdate is the result of a node-set creation like this:
<xsl:variable name="Fields_MappedForUpdate" select="fx:node-set($xx_fields)"/>

Most notably, this looks like you have something as follows (but I am guessing now):


<xsl:variable name="Fields_MappedForUpdate" select="fx:node-set($xx_fields)" />
<xsl:variable name="xx_fields">
<Field>Something</Field>
<Field>Something</Field>
.....
</xsl:variable>


Since you have an IOOB error in your .NET code, I assume (guessing again), that the select statement above should produce some output for you and that *with* the "/Field" it does not (like you said). The output must be of a certain form to prevent the IOOB error from occurring (which prompts me to add: some check on the output from the transformation would probably be a good idea).

Still guessing, the most likely cause when nodes suddenly don't match, is a wrong namespace. Since you use a variable, the namespace is the null-namespace (unless the nodes specifically are set with a namespace). If your default namespace differs, you will not have a match. The following example shows this:

<xsl:stylesheet version="1.0"
xmlns = "urn:test"
xmlns:exsl="http://exslt.org/common"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:variable name="data">
<one>This is one</one>
</xsl:variable>
<xsl:template match="/">
<test>
<!-- still inside namespace urn:test, will not match "one" -->
<xsl:apply-templates select="exsl:node-set($data)/one" />
<!-- this will match 'one' -->
<xsl:apply-templates select="exsl:node-set($data)/*[local-name() = 'one']" />
</test>
</xsl:template>
<xsl:template match="one">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>



Not sure this helps, however ;-)


Cheers,
-- Abel Braaksma
  http://www.nuntia.nl

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.