[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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.
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?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|