By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,319 Members | 1,963 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,319 IT Pros & Developers. It's quick & easy.

Possible Bug: ArgumentOutOfRangeException when using xsl:sort and xsl:strip-space has been declared

P: n/a
I have a scheduled job that uses different XSL templates to transform XML
and save it to disk. I am having problems with the code below. The problem
shows up on both my development machine (Windows XP Pro SP 1, .Net Framework
1.1) and on our production server (Windows 2K SP 4, .Net Framework 1.1). I
have simplified the code and data to isolate the problem. When I use the
xsl:strip-space (Line 12) declaration in conjunction with the xsl:sort
element located on Line 80 I get an ArgumentOutOfRangeException thrown. If I
comment out either line everything works fine. The extra twist is that there
are two xsl:sort elements in the XSL document but only one which causes the
problem. Can anyone tell me what the problem is? Or could someone else
confirm that this is a problem. I would appreciate the help. Thank you.

Regards,
Mark Miller
//------------------Code---------------------------------

class Export
{
[STAThread]
static void Main(string[] args){
try{
TextReader xmlBox =
(TextReader)File.OpenText(@"C:\Projects\XML-XSLT\SHStylesheets\Input.txt");
XPathDocument xDoc = new XPathDocument(xmlBox);
XPathNavigator xPath = xDoc.CreateNavigator();

XslTransform Xslt = new XslTransform();
Xslt.Load(@"C:\Projects\XML-XSLT\SHStylesheets\BoxScores.xsl");

StringBuilder sbXML = new StringBuilder();
StringWriter txtOutput = new StringWriter(sbXML);
try{
Xslt.Transform(xPath, null, txtOutput, null); //<---Exception is
raised here
}finally{
txtOutput.Close();
}

StreamWriter swOutput =
File.CreateText(@"C:\Projects\XML-XSLT\SHStylesheets\Output.txt");
try{
swOutput.WriteLine(sbXML.ToString());
}finally{
swOutput.Close();
}
Console.WriteLine("Success");
}catch(Exception ex){
Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
}
Console.ReadLine();
}

}

//------------------BoxScores.xsl--------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dt="urn:schemas-microsoft-com:datatypes"


<xsl:output method="text" indent="yes" omit-xml-declaration="yes"/>

<!--THIS IS THE LINE THAT WHEN COMBINED WITH THE xsl:sort BELOW CAUSES THE
PROBLEM - IF I COMMENT OUT ONE OR THE OTHER
THERE IS NO ERROR-->
<!--<xsl:strip-space elements="QUARTER1SUMMARY QUARTER2SUMMARY
QUARTER3SUMMARY QUARTER4SUMMARY OVERTIMESUMMARY"/>-->

<!--************************************************** **********************
********************************-->

<xsl:template match="/">

<xsl:value-of
select="//SPORT/@SportName"/><![CDATA[<EP>]]><xsl:text> </xsl:text>
<xsl:apply-templates select="//SCHEDULE">
<xsl:with-param name="Sport" select="//SPORT/@SportName"/>
</xsl:apply-templates>

</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template match="SCHEDULE">
<xsl:param name="Sport"/>

<xsl:text> </xsl:text>
<xsl:value-of select="@ScheduleDate"/><![CDATA[<EP>]]>
<xsl:text> </xsl:text>

<xsl:apply-templates select="GROUP1"/>
</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template name="Groupings" match="GROUP1">

<xsl:if test="string-length(@GroupName)>0">
<xsl:text> </xsl:text><![CDATA[<bold>]]>
<xsl:value-of
select="string(@GroupName)"/><![CDATA[</bold>]]><![CDATA[<EP>]]>
<xsl:text> </xsl:text>
</xsl:if>

<!--Section name-->
<!--League Name-->
<!--League Games-->
<!--"NonConference" Heading-->
<!--Non League Games-->

<xsl:apply-templates select="GROUP2/GROUP3"/>

<xsl:if test="GROUP2/GROUP3/CONTEST[@IsConferenceGame=0]">
<xsl:text> </xsl:text><![CDATA[<bold>]]>
<xsl:value-of select="'Non-League'"/><![CDATA[</bold>]]><![CDATA[<EP>]]>
<xsl:text> </xsl:text>
<xsl:apply-templates select="GROUP2/GROUP3/CONTEST[@IsConferenceGame=0]"
mode="Football">
<xsl:sort select="@ContestName" data-type="text" order="ascending"/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template name="Leagues" match="GROUP3">

<xsl:if test="string-length(@GroupName)>0 and
CONTEST[@IsConferenceGame=1]">
<xsl:text> </xsl:text><![CDATA[<bold>]]>
<xsl:value-of
select="string(@GroupName)"/><![CDATA[</bold>]]><![CDATA[<EP>]]>
<xsl:text> </xsl:text>
</xsl:if>

<xsl:choose>
<xsl:when test="//SPORT/@SportName='Football' or
//SPORT/@SportName='football'">
<xsl:apply-templates select="CONTEST[@IsConferenceGame=1]"
mode="Football">
<!--THIS IS THE LINE THAT WHEN COMBINED WITH THE xsl:strip-space ABOVE
CAUSES THE PROBLEM - IF I COMMENT OUT ONE OR THE OTHER
THERE IS NO ERROR-->
<xsl:sort select="@ContestName" data-type="text" order="ascending"/>
</xsl:apply-templates>
</xsl:when>
<!-- xsl:apply-templates FOR OTHER SPORTS -->
</xsl:choose>
</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template match="CONTEST" mode="Football">
<xsl:value-of select="@ContestName"/><![CDATA[<EP>]]>
<xsl:text> </xsl:text>

<!--
<xsl:apply-templates select="QUARTER1SUMMARY | QUARTER2SUMMARY |
QUARTER3SUMMARY | QUARTER4SUMMARY | OVERTIMESUMMARY"/>
-->
</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template match="QUARTER1SUMMARY | QUARTER2SUMMARY | QUARTER3SUMMARY |
QUARTER4SUMMARY | OVERTIMESUMMARY" mode="Football">
<xsl:if test="string-length(.)>0">
<xsl:value-of select="name(.)"/><xsl:text> - </xsl:text>
<xsl:value-of select="."/><xsl:text> </xsl:text>
</xsl:if>
</xsl:template>

<!--************************************************** **********************
********************************-->

</xsl:stylesheet>
//------------------Input.txt-------------------------------------
<SPORT SportName="football">
<SCHEDULE ScheduleDate="09-26-20">
<GROUP1 GroupName="LA City Section">
<GROUP2 GroupName="LA City Division">
<GROUP3 GroupName="Coliseum">
<CONTEST ContestName="Crenshaw 34, Hawthorne 0" IsConferenceGame="0"/>
</GROUP3>
<GROUP3 GroupName="Eastern">
<CONTEST ContestName="Bell 49, Lincoln (Los Angeles) 20"
IsConferenceGame="0"/>
<CONTEST ContestName="L. A. Jordan 21, Washington (Los Angeles) 12"
IsConferenceGame="0"/>
<CONTEST ContestName="Locke 24, South Gate 21" IsConferenceGame="0">
<QUARTER1SUMMARY>No Scoring</QUARTER1SUMMARY>
<QUARTER2SUMMARY>SG--Herrera 4 yd run SG--Pulido Kick xpt.(GOOD)
</QUARTER2SUMMARY>
<QUARTER3SUMMARY>SG--Vasquez 8 yd run SG--Pulido Kick (NO
GOOD)</QUARTER3SUMMARY>
<QUARTER4SUMMARY>SG--Kozasky 1 yd run SG--Vasquez Run xpt.
(GOOD)</QUARTER4SUMMARY>
<OVERTIMESUMMARY>
</OVERTIMESUMMARY>
</CONTEST>
</GROUP3>
<GROUP3 GroupName="Marine">
<CONTEST ContestName="Gardena 50, Franklin (Los Angeles) 12"
IsConferenceGame="0"/>
<CONTEST ContestName="Narbonne 14, Garfield 6" IsConferenceGame="0"/>
</GROUP3>
<GROUP3 GroupName="Northern">
<CONTEST ContestName="Eagle Rock 34, Hollywood 0"
IsConferenceGame="0"/>
<CONTEST ContestName="L.A. Marshall 29, Sun Valley Poly 10"
IsConferenceGame="0"/>
<CONTEST ContestName="L.A. Wilson 33, Alhambra (Alhambra) 19"
IsConferenceGame="0"/>
<CONTEST ContestName="Los Angeles 25, Palisades (Pacific Palisades)
18" IsConferenceGame="0"/>
<CONTEST ContestName="Roosevelt (Los Angeles) 44, Belmont 24"
IsConferenceGame="0">
<QUARTER1SUMMARY>Belmont--Field Goal </QUARTER1SUMMARY>
<QUARTER2SUMMARY>Belmont--50 yd. TD RUN. (conversion failed)
Roosevelt--(3:03)--Hurtado 25yd. TD RUN Roosevelt--(2:20)--Fredericks 25yd.
TD RUN</QUARTER2SUMMARY>
<QUARTER3SUMMARY>Roosevelt--(2:25)--Hurtado 4yd. TD
RUN</QUARTER3SUMMARY>
<QUARTER4SUMMARY>Roosevelt--(10:37)--Hurtado 1yd. TD RUN Belmont--TD
RUN. EXTRA POINT KICK Roosevelt--(6:16)--Padron 50yd. TD PASS from Holloway
Belmont--TD PASS. 2 PT. CONVERSION QB RUN. Roosevelt--(00:13)--Hurtado 9yd.
TD RUN</QUARTER4SUMMARY>
<OVERTIMESUMMARY>
</OVERTIMESUMMARY>
</CONTEST>
</GROUP3>
<GROUP3 GroupName="Valley Mission">
<CONTEST ContestName="North Hollywood 23, Van Nuys 6"
IsConferenceGame="0"/>
</GROUP3>
<GROUP3 GroupName="West Valley">
<CONTEST ContestName="Granada Hills 34, San Fernando 6"
IsConferenceGame="0">
<QUARTER1SUMMARY>
</QUARTER1SUMMARY>
<QUARTER2SUMMARY>
</QUARTER2SUMMARY>
<QUARTER3SUMMARY>
</QUARTER3SUMMARY>
<QUARTER4SUMMARY>
</QUARTER4SUMMARY>
<OVERTIMESUMMARY>
</OVERTIMESUMMARY>
</CONTEST>
<CONTEST ContestName="Taft (Woodland Hills) 28, Jefferson (Los Angeles)
19" IsConferenceGame="0"/>
</GROUP3>
<GROUP3 GroupName="Western">
<CONTEST ContestName="Fremont (Los Angeles) 12, L.A. University 12"
IsConferenceGame="0"/>
<CONTEST ContestName="L.A. University 12, Fremont (Los Angeles) 12"
IsConferenceGame="0"/>
<CONTEST ContestName="San Pedro 31, Westchester 0"
IsConferenceGame="0"/>
</GROUP3>
</GROUP2>
</GROUP1>
</SCHEDULE>
</SPORT>
Nov 11 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
I am sorry, I uncommented the xsl:strip line but I cannot reproduce your
problem.

I am invoking .Net xsltTransform using the nXSLT.exe command-line utility.

My configuration: W2K (latest SP), .Net Framework 1.1
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
"Mark Miller" <no**********@waveshift.com> wrote in message
news:u4**************@TK2MSFTNGP09.phx.gbl...
I have a scheduled job that uses different XSL templates to transform XML
and save it to disk. I am having problems with the code below. The problem
shows up on both my development machine (Windows XP Pro SP 1, .Net Framework 1.1) and on our production server (Windows 2K SP 4, .Net Framework 1.1). I
have simplified the code and data to isolate the problem. When I use the
xsl:strip-space (Line 12) declaration in conjunction with the xsl:sort
element located on Line 80 I get an ArgumentOutOfRangeException thrown. If I comment out either line everything works fine. The extra twist is that there are two xsl:sort elements in the XSL document but only one which causes the problem. Can anyone tell me what the problem is? Or could someone else
confirm that this is a problem. I would appreciate the help. Thank you.

Regards,
Mark Miller
//------------------Code---------------------------------

class Export
{
[STAThread]
static void Main(string[] args){
try{
TextReader xmlBox =
(TextReader)File.OpenText(@"C:\Projects\XML-XSLT\SHStylesheets\Input.txt"); XPathDocument xDoc = new XPathDocument(xmlBox);
XPathNavigator xPath = xDoc.CreateNavigator();

XslTransform Xslt = new XslTransform();
Xslt.Load(@"C:\Projects\XML-XSLT\SHStylesheets\BoxScores.xsl");

StringBuilder sbXML = new StringBuilder();
StringWriter txtOutput = new StringWriter(sbXML);
try{
Xslt.Transform(xPath, null, txtOutput, null); //<---Exception is
raised here
}finally{
txtOutput.Close();
}

StreamWriter swOutput =
File.CreateText(@"C:\Projects\XML-XSLT\SHStylesheets\Output.txt");
try{
swOutput.WriteLine(sbXML.ToString());
}finally{
swOutput.Close();
}
Console.WriteLine("Success");
}catch(Exception ex){
Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
}
Console.ReadLine();
}

}

//------------------BoxScores.xsl--------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dt="urn:schemas-microsoft-com:datatypes"

<xsl:output method="text" indent="yes" omit-xml-declaration="yes"/>

<!--THIS IS THE LINE THAT WHEN COMBINED WITH THE xsl:sort BELOW CAUSES THE
PROBLEM - IF I COMMENT OUT ONE OR THE OTHER
THERE IS NO ERROR-->
<!--<xsl:strip-space elements="QUARTER1SUMMARY QUARTER2SUMMARY
QUARTER3SUMMARY QUARTER4SUMMARY OVERTIMESUMMARY"/>-->

<!--************************************************** ********************** ********************************-->

<xsl:template match="/">

<xsl:value-of
select="//SPORT/@SportName"/><![CDATA[<EP>]]><xsl:text> </xsl:text> <xsl:apply-templates select="//SCHEDULE">
<xsl:with-param name="Sport" select="//SPORT/@SportName"/>
</xsl:apply-templates>

</xsl:template>

<!--************************************************** ********************** ********************************-->

<xsl:template match="SCHEDULE">
<xsl:param name="Sport"/>

<xsl:text> </xsl:text>
<xsl:value-of select="@ScheduleDate"/><![CDATA[<EP>]]>
<xsl:text> </xsl:text>

<xsl:apply-templates select="GROUP1"/>
</xsl:template>

<!--************************************************** ********************** ********************************-->

<xsl:template name="Groupings" match="GROUP1">

<xsl:if test="string-length(@GroupName)>0">
<xsl:text> </xsl:text><![CDATA[<bold>]]>
<xsl:value-of
select="string(@GroupName)"/><![CDATA[</bold>]]><![CDATA[<EP>]]>
<xsl:text> </xsl:text>
</xsl:if>

<!--Section name-->
<!--League Name-->
<!--League Games-->
<!--"NonConference" Heading-->
<!--Non League Games-->

<xsl:apply-templates select="GROUP2/GROUP3"/>

<xsl:if test="GROUP2/GROUP3/CONTEST[@IsConferenceGame=0]">
<xsl:text> </xsl:text><![CDATA[<bold>]]>
<xsl:value-of select="'Non-League'"/><![CDATA[</bold>]]><![CDATA[<EP>]]> <xsl:text> </xsl:text>
<xsl:apply-templates select="GROUP2/GROUP3/CONTEST[@IsConferenceGame=0]" mode="Football">
<xsl:sort select="@ContestName" data-type="text" order="ascending"/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>

<!--************************************************** ********************** ********************************-->

<xsl:template name="Leagues" match="GROUP3">

<xsl:if test="string-length(@GroupName)>0 and
CONTEST[@IsConferenceGame=1]">
<xsl:text> </xsl:text><![CDATA[<bold>]]>
<xsl:value-of
select="string(@GroupName)"/><![CDATA[</bold>]]><![CDATA[<EP>]]>
<xsl:text> </xsl:text>
</xsl:if>

<xsl:choose>
<xsl:when test="//SPORT/@SportName='Football' or
//SPORT/@SportName='football'">
<xsl:apply-templates select="CONTEST[@IsConferenceGame=1]"
mode="Football">
<!--THIS IS THE LINE THAT WHEN COMBINED WITH THE xsl:strip-space ABOVE CAUSES THE PROBLEM - IF I COMMENT OUT ONE OR THE OTHER
THERE IS NO ERROR-->
<xsl:sort select="@ContestName" data-type="text" order="ascending"/>
</xsl:apply-templates>
</xsl:when>
<!-- xsl:apply-templates FOR OTHER SPORTS -->
</xsl:choose>
</xsl:template>

<!--************************************************** ********************** ********************************-->

<xsl:template match="CONTEST" mode="Football">
<xsl:value-of select="@ContestName"/><![CDATA[<EP>]]>
<xsl:text> </xsl:text>

<!--
<xsl:apply-templates select="QUARTER1SUMMARY | QUARTER2SUMMARY |
QUARTER3SUMMARY | QUARTER4SUMMARY | OVERTIMESUMMARY"/>
-->
</xsl:template>

<!--************************************************** ********************** ********************************-->

<xsl:template match="QUARTER1SUMMARY | QUARTER2SUMMARY | QUARTER3SUMMARY |
QUARTER4SUMMARY | OVERTIMESUMMARY" mode="Football">
<xsl:if test="string-length(.)>0">
<xsl:value-of select="name(.)"/><xsl:text> - </xsl:text>
<xsl:value-of select="."/><xsl:text> </xsl:text>
</xsl:if>
</xsl:template>

<!--************************************************** ********************** ********************************-->

</xsl:stylesheet>
//------------------Input.txt-------------------------------------
<SPORT SportName="football">
<SCHEDULE ScheduleDate="09-26-20">
<GROUP1 GroupName="LA City Section">
<GROUP2 GroupName="LA City Division">
<GROUP3 GroupName="Coliseum">
<CONTEST ContestName="Crenshaw 34, Hawthorne 0" IsConferenceGame="0"/> </GROUP3>
<GROUP3 GroupName="Eastern">
<CONTEST ContestName="Bell 49, Lincoln (Los Angeles) 20"
IsConferenceGame="0"/>
<CONTEST ContestName="L. A. Jordan 21, Washington (Los Angeles) 12"
IsConferenceGame="0"/>
<CONTEST ContestName="Locke 24, South Gate 21" IsConferenceGame="0">
<QUARTER1SUMMARY>No Scoring</QUARTER1SUMMARY>
<QUARTER2SUMMARY>SG--Herrera 4 yd run SG--Pulido Kick xpt.(GOOD)
</QUARTER2SUMMARY>
<QUARTER3SUMMARY>SG--Vasquez 8 yd run SG--Pulido Kick (NO
GOOD)</QUARTER3SUMMARY>
<QUARTER4SUMMARY>SG--Kozasky 1 yd run SG--Vasquez Run xpt.
(GOOD)</QUARTER4SUMMARY>
<OVERTIMESUMMARY>
</OVERTIMESUMMARY>
</CONTEST>
</GROUP3>
<GROUP3 GroupName="Marine">
<CONTEST ContestName="Gardena 50, Franklin (Los Angeles) 12"
IsConferenceGame="0"/>
<CONTEST ContestName="Narbonne 14, Garfield 6" IsConferenceGame="0"/> </GROUP3>
<GROUP3 GroupName="Northern">
<CONTEST ContestName="Eagle Rock 34, Hollywood 0"
IsConferenceGame="0"/>
<CONTEST ContestName="L.A. Marshall 29, Sun Valley Poly 10"
IsConferenceGame="0"/>
<CONTEST ContestName="L.A. Wilson 33, Alhambra (Alhambra) 19"
IsConferenceGame="0"/>
<CONTEST ContestName="Los Angeles 25, Palisades (Pacific Palisades)
18" IsConferenceGame="0"/>
<CONTEST ContestName="Roosevelt (Los Angeles) 44, Belmont 24"
IsConferenceGame="0">
<QUARTER1SUMMARY>Belmont--Field Goal </QUARTER1SUMMARY>
<QUARTER2SUMMARY>Belmont--50 yd. TD RUN. (conversion failed)
Roosevelt--(3:03)--Hurtado 25yd. TD RUN Roosevelt--(2:20)--Fredericks 25yd. TD RUN</QUARTER2SUMMARY>
<QUARTER3SUMMARY>Roosevelt--(2:25)--Hurtado 4yd. TD
RUN</QUARTER3SUMMARY>
<QUARTER4SUMMARY>Roosevelt--(10:37)--Hurtado 1yd. TD RUN Belmont--TD RUN. EXTRA POINT KICK Roosevelt--(6:16)--Padron 50yd. TD PASS from Holloway Belmont--TD PASS. 2 PT. CONVERSION QB RUN. Roosevelt--(00:13)--Hurtado 9yd. TD RUN</QUARTER4SUMMARY>
<OVERTIMESUMMARY>
</OVERTIMESUMMARY>
</CONTEST>
</GROUP3>
<GROUP3 GroupName="Valley Mission">
<CONTEST ContestName="North Hollywood 23, Van Nuys 6"
IsConferenceGame="0"/>
</GROUP3>
<GROUP3 GroupName="West Valley">
<CONTEST ContestName="Granada Hills 34, San Fernando 6"
IsConferenceGame="0">
<QUARTER1SUMMARY>
</QUARTER1SUMMARY>
<QUARTER2SUMMARY>
</QUARTER2SUMMARY>
<QUARTER3SUMMARY>
</QUARTER3SUMMARY>
<QUARTER4SUMMARY>
</QUARTER4SUMMARY>
<OVERTIMESUMMARY>
</OVERTIMESUMMARY>
</CONTEST>
<CONTEST ContestName="Taft (Woodland Hills) 28, Jefferson (Los Angeles) 19" IsConferenceGame="0"/>
</GROUP3>
<GROUP3 GroupName="Western">
<CONTEST ContestName="Fremont (Los Angeles) 12, L.A. University 12"
IsConferenceGame="0"/>
<CONTEST ContestName="L.A. University 12, Fremont (Los Angeles) 12"
IsConferenceGame="0"/>
<CONTEST ContestName="San Pedro 31, Westchester 0"
IsConferenceGame="0"/>
</GROUP3>
</GROUP2>
</GROUP1>
</SCHEDULE>
</SPORT>

Nov 11 '05 #2

P: n/a
I appreciate the response. I'll check to see if the same will work on my
system. However, I need to be able to use Transform from a class because I
am getting the XML from Sql server, so is there any way you could tell me
what is wrong with my code then? I am calling this from a compiled exe
(project type console application).

Regards,
Mark
"Dimitre Novatchev" <dn********@yahoo.com> wrote in message
news:bl************@ID-152440.news.uni-berlin.de...
I am sorry, I uncommented the xsl:strip line but I cannot reproduce your
problem.

I am invoking .Net xsltTransform using the nXSLT.exe command-line utility.

My configuration: W2K (latest SP), .Net Framework 1.1
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
"Mark Miller" <no**********@waveshift.com> wrote in message
news:u4**************@TK2MSFTNGP09.phx.gbl...
I have a scheduled job that uses different XSL templates to transform XML and save it to disk. I am having problems with the code below. The problem shows up on both my development machine (Windows XP Pro SP 1, .Net Framework
1.1) and on our production server (Windows 2K SP 4, .Net Framework 1.1). I have simplified the code and data to isolate the problem. When I use the
xsl:strip-space (Line 12) declaration in conjunction with the xsl:sort
element located on Line 80 I get an ArgumentOutOfRangeException thrown. If I
comment out either line everything works fine. The extra twist is that

there
are two xsl:sort elements in the XSL document but only one which causes

the
problem. Can anyone tell me what the problem is? Or could someone else
confirm that this is a problem. I would appreciate the help. Thank you.

Regards,
Mark Miller
//------------------Code---------------------------------

class Export
{
[STAThread]
static void Main(string[] args){
try{
TextReader xmlBox =

(TextReader)File.OpenText(@"C:\Projects\XML-XSLT\SHStylesheets\Input.txt"); XPathDocument xDoc = new XPathDocument(xmlBox);
XPathNavigator xPath = xDoc.CreateNavigator();

XslTransform Xslt = new XslTransform();
Xslt.Load(@"C:\Projects\XML-XSLT\SHStylesheets\BoxScores.xsl");

StringBuilder sbXML = new StringBuilder();
StringWriter txtOutput = new StringWriter(sbXML);
try{
Xslt.Transform(xPath, null, txtOutput, null); //<---Exception is
raised here
}finally{
txtOutput.Close();
}

StreamWriter swOutput =
File.CreateText(@"C:\Projects\XML-XSLT\SHStylesheets\Output.txt");
try{
swOutput.WriteLine(sbXML.ToString());
}finally{
swOutput.Close();
}
Console.WriteLine("Success");
}catch(Exception ex){
Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
}
Console.ReadLine();
}

}

//------------------BoxScores.xsl--------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dt="urn:schemas-microsoft-com:datatypes"


<xsl:output method="text" indent="yes" omit-xml-declaration="yes"/>

<!--THIS IS THE LINE THAT WHEN COMBINED WITH THE xsl:sort BELOW CAUSES THE PROBLEM - IF I COMMENT OUT ONE OR THE OTHER
THERE IS NO ERROR-->
<!--<xsl:strip-space elements="QUARTER1SUMMARY QUARTER2SUMMARY
QUARTER3SUMMARY QUARTER4SUMMARY OVERTIMESUMMARY"/>-->

<!--************************************************** **********************
********************************-->

<xsl:template match="/">

<xsl:value-of

select="//SPORT/@SportName"/><![CDATA[<EP>]]><xsl:text> </xsl:text>
<xsl:apply-templates select="//SCHEDULE">
<xsl:with-param name="Sport" select="//SPORT/@SportName"/>
</xsl:apply-templates>

</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template match="SCHEDULE">
<xsl:param name="Sport"/>

<xsl:text> </xsl:text>
<xsl:value-of select="@ScheduleDate"/><![CDATA[<EP>]]>
<xsl:text> </xsl:text>

<xsl:apply-templates select="GROUP1"/>
</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template name="Groupings" match="GROUP1">

<xsl:if test="string-length(@GroupName)>0">
<xsl:text> </xsl:text><![CDATA[<bold>]]>
<xsl:value-of
select="string(@GroupName)"/><![CDATA[</bold>]]><![CDATA[<EP>]]>
<xsl:text> </xsl:text>
</xsl:if>

<!--Section name-->
<!--League Name-->
<!--League Games-->
<!--"NonConference" Heading-->
<!--Non League Games-->

<xsl:apply-templates select="GROUP2/GROUP3"/>

<xsl:if test="GROUP2/GROUP3/CONTEST[@IsConferenceGame=0]">
<xsl:text> </xsl:text><![CDATA[<bold>]]>
<xsl:value-of

select="'Non-League'"/><![CDATA[</bold>]]><![CDATA[<EP>]]>
<xsl:text> </xsl:text>
<xsl:apply-templates

select="GROUP2/GROUP3/CONTEST[@IsConferenceGame=0]"
mode="Football">
<xsl:sort select="@ContestName" data-type="text" order="ascending"/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template name="Leagues" match="GROUP3">

<xsl:if test="string-length(@GroupName)>0 and
CONTEST[@IsConferenceGame=1]">
<xsl:text> </xsl:text><![CDATA[<bold>]]>
<xsl:value-of
select="string(@GroupName)"/><![CDATA[</bold>]]><![CDATA[<EP>]]>
<xsl:text> </xsl:text>
</xsl:if>

<xsl:choose>
<xsl:when test="//SPORT/@SportName='Football' or
//SPORT/@SportName='football'">
<xsl:apply-templates select="CONTEST[@IsConferenceGame=1]"
mode="Football">
<!--THIS IS THE LINE THAT WHEN COMBINED WITH THE xsl:strip-space

ABOVE
CAUSES THE PROBLEM - IF I COMMENT OUT ONE OR THE OTHER
THERE IS NO ERROR-->
<xsl:sort select="@ContestName" data-type="text" order="ascending"/> </xsl:apply-templates>
</xsl:when>
<!-- xsl:apply-templates FOR OTHER SPORTS -->
</xsl:choose>
</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template match="CONTEST" mode="Football">
<xsl:value-of select="@ContestName"/><![CDATA[<EP>]]>
<xsl:text> </xsl:text>

<!--
<xsl:apply-templates select="QUARTER1SUMMARY | QUARTER2SUMMARY |
QUARTER3SUMMARY | QUARTER4SUMMARY | OVERTIMESUMMARY"/>
-->
</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template match="QUARTER1SUMMARY | QUARTER2SUMMARY | QUARTER3SUMMARY | QUARTER4SUMMARY | OVERTIMESUMMARY" mode="Football">
<xsl:if test="string-length(.)>0">
<xsl:value-of select="name(.)"/><xsl:text> - </xsl:text>
<xsl:value-of select="."/><xsl:text> </xsl:text>
</xsl:if>
</xsl:template>

<!--************************************************** **********************
********************************-->

</xsl:stylesheet>
//------------------Input.txt-------------------------------------
<SPORT SportName="football">
<SCHEDULE ScheduleDate="09-26-20">
<GROUP1 GroupName="LA City Section">
<GROUP2 GroupName="LA City Division">
<GROUP3 GroupName="Coliseum">
<CONTEST ContestName="Crenshaw 34, Hawthorne 0"

IsConferenceGame="0"/>
</GROUP3>
<GROUP3 GroupName="Eastern">
<CONTEST ContestName="Bell 49, Lincoln (Los Angeles) 20"
IsConferenceGame="0"/>
<CONTEST ContestName="L. A. Jordan 21, Washington (Los Angeles) 12"
IsConferenceGame="0"/>
<CONTEST ContestName="Locke 24, South Gate 21" IsConferenceGame="0"> <QUARTER1SUMMARY>No Scoring</QUARTER1SUMMARY>
<QUARTER2SUMMARY>SG--Herrera 4 yd run SG--Pulido Kick xpt.(GOOD)
</QUARTER2SUMMARY>
<QUARTER3SUMMARY>SG--Vasquez 8 yd run SG--Pulido Kick (NO
GOOD)</QUARTER3SUMMARY>
<QUARTER4SUMMARY>SG--Kozasky 1 yd run SG--Vasquez Run xpt.
(GOOD)</QUARTER4SUMMARY>
<OVERTIMESUMMARY>
</OVERTIMESUMMARY>
</CONTEST>
</GROUP3>
<GROUP3 GroupName="Marine">
<CONTEST ContestName="Gardena 50, Franklin (Los Angeles) 12"
IsConferenceGame="0"/>
<CONTEST ContestName="Narbonne 14, Garfield 6"

IsConferenceGame="0"/>
</GROUP3>
<GROUP3 GroupName="Northern">
<CONTEST ContestName="Eagle Rock 34, Hollywood 0"
IsConferenceGame="0"/>
<CONTEST ContestName="L.A. Marshall 29, Sun Valley Poly 10"
IsConferenceGame="0"/>
<CONTEST ContestName="L.A. Wilson 33, Alhambra (Alhambra) 19"
IsConferenceGame="0"/>
<CONTEST ContestName="Los Angeles 25, Palisades (Pacific Palisades) 18" IsConferenceGame="0"/>
<CONTEST ContestName="Roosevelt (Los Angeles) 44, Belmont 24"
IsConferenceGame="0">
<QUARTER1SUMMARY>Belmont--Field Goal </QUARTER1SUMMARY>
<QUARTER2SUMMARY>Belmont--50 yd. TD RUN. (conversion failed)
Roosevelt--(3:03)--Hurtado 25yd. TD RUN Roosevelt--(2:20)--Fredericks

25yd.
TD RUN</QUARTER2SUMMARY>
<QUARTER3SUMMARY>Roosevelt--(2:25)--Hurtado 4yd. TD
RUN</QUARTER3SUMMARY>
<QUARTER4SUMMARY>Roosevelt--(10:37)--Hurtado 1yd. TD RUN

Belmont--TD
RUN. EXTRA POINT KICK Roosevelt--(6:16)--Padron 50yd. TD PASS from

Holloway
Belmont--TD PASS. 2 PT. CONVERSION QB RUN. Roosevelt--(00:13)--Hurtado

9yd.
TD RUN</QUARTER4SUMMARY>
<OVERTIMESUMMARY>
</OVERTIMESUMMARY>
</CONTEST>
</GROUP3>
<GROUP3 GroupName="Valley Mission">
<CONTEST ContestName="North Hollywood 23, Van Nuys 6"
IsConferenceGame="0"/>
</GROUP3>
<GROUP3 GroupName="West Valley">
<CONTEST ContestName="Granada Hills 34, San Fernando 6"
IsConferenceGame="0">
<QUARTER1SUMMARY>
</QUARTER1SUMMARY>
<QUARTER2SUMMARY>
</QUARTER2SUMMARY>
<QUARTER3SUMMARY>
</QUARTER3SUMMARY>
<QUARTER4SUMMARY>
</QUARTER4SUMMARY>
<OVERTIMESUMMARY>
</OVERTIMESUMMARY>
</CONTEST>
<CONTEST ContestName="Taft (Woodland Hills) 28, Jefferson (Los

Angeles)
19" IsConferenceGame="0"/>
</GROUP3>
<GROUP3 GroupName="Western">
<CONTEST ContestName="Fremont (Los Angeles) 12, L.A. University 12"
IsConferenceGame="0"/>
<CONTEST ContestName="L.A. University 12, Fremont (Los Angeles) 12"
IsConferenceGame="0"/>
<CONTEST ContestName="San Pedro 31, Westchester 0"
IsConferenceGame="0"/>
</GROUP3>
</GROUP2>
</GROUP1>
</SCHEDULE>
</SPORT>


Nov 11 '05 #3

P: n/a
I have run the stylesheet w/ nXslt.exe and confirmed that yes it does work
fine. However, I still am getting the following when I run it with my code
from a console app:

Index was out of range. Must be non-negative and less than the size of the
collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at System.Xml.Xsl.XPathSortArrayIterator.get_Current( )
at System.Xml.Xsl.ActionFrame.NewNextNode(Processor proc)
at System.Xml.Xsl.ApplyTemplatesAction.Execute(Proces sor processor,
ActionFrame frame)
at System.Xml.Xsl.ActionFrame.Execute(Processor processor)
at System.Xml.Xsl.Processor.Execute()
at System.Xml.Xsl.XslTransform.Transform(XPathNavigat or input,
XsltArgumentList args, TextWriter output, XmlResolver resolver)
at Sporsthuddle.Components.SH_XMLAutoExport.Export.Ma in(String[] args) in
c:\projects\components\sportshuddle\sh_xmlautoexpo rt\export.cs:line 40

Could someone PLEASE let me know what I am doing wrong?

Regards,
Mark

"Dimitre Novatchev" <dn********@yahoo.com> wrote in message
news:bl************@ID-152440.news.uni-berlin.de...
I am sorry, I uncommented the xsl:strip line but I cannot reproduce your
problem.

I am invoking .Net xsltTransform using the nXSLT.exe command-line utility.

My configuration: W2K (latest SP), .Net Framework 1.1
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
"Mark Miller" <no**********@waveshift.com> wrote in message
news:u4**************@TK2MSFTNGP09.phx.gbl...
I have a scheduled job that uses different XSL templates to transform XML and save it to disk. I am having problems with the code below. The problem shows up on both my development machine (Windows XP Pro SP 1, .Net Framework
1.1) and on our production server (Windows 2K SP 4, .Net Framework 1.1). I have simplified the code and data to isolate the problem. When I use the
xsl:strip-space (Line 12) declaration in conjunction with the xsl:sort
element located on Line 80 I get an ArgumentOutOfRangeException thrown. If I
comment out either line everything works fine. The extra twist is that

there
are two xsl:sort elements in the XSL document but only one which causes

the
problem. Can anyone tell me what the problem is? Or could someone else
confirm that this is a problem. I would appreciate the help. Thank you.

Regards,
Mark Miller
//------------------Code---------------------------------

class Export
{
[STAThread]
static void Main(string[] args){
try{
TextReader xmlBox =

(TextReader)File.OpenText(@"C:\Projects\XML-XSLT\SHStylesheets\Input.txt"); XPathDocument xDoc = new XPathDocument(xmlBox);
XPathNavigator xPath = xDoc.CreateNavigator();

XslTransform Xslt = new XslTransform();
Xslt.Load(@"C:\Projects\XML-XSLT\SHStylesheets\BoxScores.xsl");

StringBuilder sbXML = new StringBuilder();
StringWriter txtOutput = new StringWriter(sbXML);
try{
Xslt.Transform(xPath, null, txtOutput, null); //<---Exception is
raised here
}finally{
txtOutput.Close();
}

StreamWriter swOutput =
File.CreateText(@"C:\Projects\XML-XSLT\SHStylesheets\Output.txt");
try{
swOutput.WriteLine(sbXML.ToString());
}finally{
swOutput.Close();
}
Console.WriteLine("Success");
}catch(Exception ex){
Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
}
Console.ReadLine();
}

}

//------------------BoxScores.xsl--------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dt="urn:schemas-microsoft-com:datatypes"


<xsl:output method="text" indent="yes" omit-xml-declaration="yes"/>

<!--THIS IS THE LINE THAT WHEN COMBINED WITH THE xsl:sort BELOW CAUSES THE PROBLEM - IF I COMMENT OUT ONE OR THE OTHER
THERE IS NO ERROR-->
<!--<xsl:strip-space elements="QUARTER1SUMMARY QUARTER2SUMMARY
QUARTER3SUMMARY QUARTER4SUMMARY OVERTIMESUMMARY"/>-->

<!--************************************************** **********************
********************************-->

<xsl:template match="/">

<xsl:value-of

select="//SPORT/@SportName"/><![CDATA[<EP>]]><xsl:text> </xsl:text>
<xsl:apply-templates select="//SCHEDULE">
<xsl:with-param name="Sport" select="//SPORT/@SportName"/>
</xsl:apply-templates>

</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template match="SCHEDULE">
<xsl:param name="Sport"/>

<xsl:text> </xsl:text>
<xsl:value-of select="@ScheduleDate"/><![CDATA[<EP>]]>
<xsl:text> </xsl:text>

<xsl:apply-templates select="GROUP1"/>
</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template name="Groupings" match="GROUP1">

<xsl:if test="string-length(@GroupName)>0">
<xsl:text> </xsl:text><![CDATA[<bold>]]>
<xsl:value-of
select="string(@GroupName)"/><![CDATA[</bold>]]><![CDATA[<EP>]]>
<xsl:text> </xsl:text>
</xsl:if>

<!--Section name-->
<!--League Name-->
<!--League Games-->
<!--"NonConference" Heading-->
<!--Non League Games-->

<xsl:apply-templates select="GROUP2/GROUP3"/>

<xsl:if test="GROUP2/GROUP3/CONTEST[@IsConferenceGame=0]">
<xsl:text> </xsl:text><![CDATA[<bold>]]>
<xsl:value-of

select="'Non-League'"/><![CDATA[</bold>]]><![CDATA[<EP>]]>
<xsl:text> </xsl:text>
<xsl:apply-templates

select="GROUP2/GROUP3/CONTEST[@IsConferenceGame=0]"
mode="Football">
<xsl:sort select="@ContestName" data-type="text" order="ascending"/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template name="Leagues" match="GROUP3">

<xsl:if test="string-length(@GroupName)>0 and
CONTEST[@IsConferenceGame=1]">
<xsl:text> </xsl:text><![CDATA[<bold>]]>
<xsl:value-of
select="string(@GroupName)"/><![CDATA[</bold>]]><![CDATA[<EP>]]>
<xsl:text> </xsl:text>
</xsl:if>

<xsl:choose>
<xsl:when test="//SPORT/@SportName='Football' or
//SPORT/@SportName='football'">
<xsl:apply-templates select="CONTEST[@IsConferenceGame=1]"
mode="Football">
<!--THIS IS THE LINE THAT WHEN COMBINED WITH THE xsl:strip-space

ABOVE
CAUSES THE PROBLEM - IF I COMMENT OUT ONE OR THE OTHER
THERE IS NO ERROR-->
<xsl:sort select="@ContestName" data-type="text" order="ascending"/> </xsl:apply-templates>
</xsl:when>
<!-- xsl:apply-templates FOR OTHER SPORTS -->
</xsl:choose>
</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template match="CONTEST" mode="Football">
<xsl:value-of select="@ContestName"/><![CDATA[<EP>]]>
<xsl:text> </xsl:text>

<!--
<xsl:apply-templates select="QUARTER1SUMMARY | QUARTER2SUMMARY |
QUARTER3SUMMARY | QUARTER4SUMMARY | OVERTIMESUMMARY"/>
-->
</xsl:template>

<!--************************************************** **********************
********************************-->

<xsl:template match="QUARTER1SUMMARY | QUARTER2SUMMARY | QUARTER3SUMMARY | QUARTER4SUMMARY | OVERTIMESUMMARY" mode="Football">
<xsl:if test="string-length(.)>0">
<xsl:value-of select="name(.)"/><xsl:text> - </xsl:text>
<xsl:value-of select="."/><xsl:text> </xsl:text>
</xsl:if>
</xsl:template>

<!--************************************************** **********************
********************************-->

</xsl:stylesheet>
//------------------Input.txt-------------------------------------
<SPORT SportName="football">
<SCHEDULE ScheduleDate="09-26-20">
<GROUP1 GroupName="LA City Section">
<GROUP2 GroupName="LA City Division">
<GROUP3 GroupName="Coliseum">
<CONTEST ContestName="Crenshaw 34, Hawthorne 0"

IsConferenceGame="0"/>
</GROUP3>
<GROUP3 GroupName="Eastern">
<CONTEST ContestName="Bell 49, Lincoln (Los Angeles) 20"
IsConferenceGame="0"/>
<CONTEST ContestName="L. A. Jordan 21, Washington (Los Angeles) 12"
IsConferenceGame="0"/>
<CONTEST ContestName="Locke 24, South Gate 21" IsConferenceGame="0"> <QUARTER1SUMMARY>No Scoring</QUARTER1SUMMARY>
<QUARTER2SUMMARY>SG--Herrera 4 yd run SG--Pulido Kick xpt.(GOOD)
</QUARTER2SUMMARY>
<QUARTER3SUMMARY>SG--Vasquez 8 yd run SG--Pulido Kick (NO
GOOD)</QUARTER3SUMMARY>
<QUARTER4SUMMARY>SG--Kozasky 1 yd run SG--Vasquez Run xpt.
(GOOD)</QUARTER4SUMMARY>
<OVERTIMESUMMARY>
</OVERTIMESUMMARY>
</CONTEST>
</GROUP3>
<GROUP3 GroupName="Marine">
<CONTEST ContestName="Gardena 50, Franklin (Los Angeles) 12"
IsConferenceGame="0"/>
<CONTEST ContestName="Narbonne 14, Garfield 6"

IsConferenceGame="0"/>
</GROUP3>
<GROUP3 GroupName="Northern">
<CONTEST ContestName="Eagle Rock 34, Hollywood 0"
IsConferenceGame="0"/>
<CONTEST ContestName="L.A. Marshall 29, Sun Valley Poly 10"
IsConferenceGame="0"/>
<CONTEST ContestName="L.A. Wilson 33, Alhambra (Alhambra) 19"
IsConferenceGame="0"/>
<CONTEST ContestName="Los Angeles 25, Palisades (Pacific Palisades) 18" IsConferenceGame="0"/>
<CONTEST ContestName="Roosevelt (Los Angeles) 44, Belmont 24"
IsConferenceGame="0">
<QUARTER1SUMMARY>Belmont--Field Goal </QUARTER1SUMMARY>
<QUARTER2SUMMARY>Belmont--50 yd. TD RUN. (conversion failed)
Roosevelt--(3:03)--Hurtado 25yd. TD RUN Roosevelt--(2:20)--Fredericks

25yd.
TD RUN</QUARTER2SUMMARY>
<QUARTER3SUMMARY>Roosevelt--(2:25)--Hurtado 4yd. TD
RUN</QUARTER3SUMMARY>
<QUARTER4SUMMARY>Roosevelt--(10:37)--Hurtado 1yd. TD RUN

Belmont--TD
RUN. EXTRA POINT KICK Roosevelt--(6:16)--Padron 50yd. TD PASS from

Holloway
Belmont--TD PASS. 2 PT. CONVERSION QB RUN. Roosevelt--(00:13)--Hurtado

9yd.
TD RUN</QUARTER4SUMMARY>
<OVERTIMESUMMARY>
</OVERTIMESUMMARY>
</CONTEST>
</GROUP3>
<GROUP3 GroupName="Valley Mission">
<CONTEST ContestName="North Hollywood 23, Van Nuys 6"
IsConferenceGame="0"/>
</GROUP3>
<GROUP3 GroupName="West Valley">
<CONTEST ContestName="Granada Hills 34, San Fernando 6"
IsConferenceGame="0">
<QUARTER1SUMMARY>
</QUARTER1SUMMARY>
<QUARTER2SUMMARY>
</QUARTER2SUMMARY>
<QUARTER3SUMMARY>
</QUARTER3SUMMARY>
<QUARTER4SUMMARY>
</QUARTER4SUMMARY>
<OVERTIMESUMMARY>
</OVERTIMESUMMARY>
</CONTEST>
<CONTEST ContestName="Taft (Woodland Hills) 28, Jefferson (Los

Angeles)
19" IsConferenceGame="0"/>
</GROUP3>
<GROUP3 GroupName="Western">
<CONTEST ContestName="Fremont (Los Angeles) 12, L.A. University 12"
IsConferenceGame="0"/>
<CONTEST ContestName="L.A. University 12, Fremont (Los Angeles) 12"
IsConferenceGame="0"/>
<CONTEST ContestName="San Pedro 31, Westchester 0"
IsConferenceGame="0"/>
</GROUP3>
</GROUP2>
</GROUP1>
</SCHEDULE>
</SPORT>


Nov 11 '05 #4

P: n/a
Mark Miller wrote:
I have run the stylesheet w/ nXslt.exe and confirmed that yes it does work
fine. However, I still am getting the following when I run it with my code
from a console app:

Index was out of range. Must be non-negative and less than the size of the
collection.
Parameter name: index


Yeah, I get the same exception. It only appears under .NET 1.1. Works fine in
..NET 1.0 and nxslt.exe (hmmm, apparently it uses .NET 1.0).
There is something wrong with sorting when apply-templates selects empty nodeset.

<xsl:apply-templates select="CONTEST[@IsConferenceGame=1]"
mode="Football">
<xsl:sort select="@ContestName" data-type="text" order="ascending"/>
</xsl:apply-templates>

Here CONTEST[@IsConferenceGame=1] is empty nodeset, because there is no such
elements in XML. That stimulate the bug to appear.

You can use simple workaround, which should work:
<xsl:if test="CONTEST[@IsConferenceGame=1]">
<xsl:apply-templates select="CONTEST[@IsConferenceGame=1]"
mode="Football">
<xsl:sort select="@ContestName" data-type="text" order="ascending"/>
</xsl:apply-templates>
</xsl:if>
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #5

P: n/a
Yes, this is a bug in .Net 1.1. It will be fixed in SP1.

-Helena Kupkova, MS

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message
news:eP*************@TK2MSFTNGP12.phx.gbl...
Mark Miller wrote:
I have run the stylesheet w/ nXslt.exe and confirmed that yes it does work fine. However, I still am getting the following when I run it with my code from a console app:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Yeah, I get the same exception. It only appears under .NET 1.1. Works fine

in .NET 1.0 and nxslt.exe (hmmm, apparently it uses .NET 1.0).
There is something wrong with sorting when apply-templates selects empty nodeset.
<xsl:apply-templates select="CONTEST[@IsConferenceGame=1]"
mode="Football">
<xsl:sort select="@ContestName" data-type="text" order="ascending"/>
</xsl:apply-templates>

Here CONTEST[@IsConferenceGame=1] is empty nodeset, because there is no such elements in XML. That stimulate the bug to appear.

You can use simple workaround, which should work:
<xsl:if test="CONTEST[@IsConferenceGame=1]">
<xsl:apply-templates select="CONTEST[@IsConferenceGame=1]"
mode="Football">
<xsl:sort select="@ContestName" data-type="text" order="ascending"/>
</xsl:apply-templates>
</xsl:if>
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #6

P: n/a
Is there a release date for SP 1?
"SQL Server Development Team [MSFT]" <sq****@microsoft.com> wrote in message
news:uh*************@TK2MSFTNGP12.phx.gbl...
Yes, this is a bug in .Net 1.1. It will be fixed in SP1.

-Helena Kupkova, MS

--
This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message
news:eP*************@TK2MSFTNGP12.phx.gbl...
Mark Miller wrote:
I have run the stylesheet w/ nXslt.exe and confirmed that yes it does work fine. However, I still am getting the following when I run it with my code from a console app:

Index was out of range. Must be non-negative and less than the size
of
the collection.
Parameter name: index
Yeah, I get the same exception. It only appears under .NET 1.1. Works fine in
.NET 1.0 and nxslt.exe (hmmm, apparently it uses .NET 1.0).
There is something wrong with sorting when apply-templates selects empty

nodeset.

<xsl:apply-templates select="CONTEST[@IsConferenceGame=1]"
mode="Football">
<xsl:sort select="@ContestName" data-type="text"

order="ascending"/> </xsl:apply-templates>

Here CONTEST[@IsConferenceGame=1] is empty nodeset, because there is no

such
elements in XML. That stimulate the bug to appear.

You can use simple workaround, which should work:
<xsl:if test="CONTEST[@IsConferenceGame=1]">
<xsl:apply-templates select="CONTEST[@IsConferenceGame=1]"
mode="Football">
<xsl:sort select="@ContestName" data-type="text" order="ascending"/> </xsl:apply-templates>
</xsl:if>
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel


Nov 11 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.