472,794 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,794 software developers and data experts.

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

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
6 2077
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AR | last post by:
Hi, How can I get strings separately which contain text nodes of a given element using XSL and XPath? For example, <a> aaa 111 <b>
9
by: David | last post by:
Hi all, I have an array of strings. For example... = "entry1 first entry"; = "entry2 second entry"; = "entry3 third entry"; etc... How can I sort this array by the number after "entry"?
3
by: Eddy C | last post by:
I'm trying to strip an XML document of unwanted nodes such that in the example below I would keep all the parent nodes of a child node I wanted and for other parents which do not have the child...
1
by: James | last post by:
Quick question: I have some text containing strings to strip out and replace: eg. "some text some text some %replacethis% text some text some text" with the % flagging what to replace. I...
3
by: Sakcee | last post by:
Hi In one of the data files that I have , I am seeing these characters \xed\xa0\xa0 . They seem to break the xsl. --------------------------------------------------------------- Extra...
2
by: CI | last post by:
I have to create a new XML document from the exising one, by adding some additional tags, etc.. My question is as follows: how to strip XML comments from the existing document? The identity...
1
by: chriscorbell | last post by:
I'm fairly new to XSLT and XPath. My question is related to some posts I found in group archives (e.g. "Disable XPath namespace matching in XSL") but is a little more specific. I want a single...
1
by: JR | last post by:
I have some code that cleans up an xml file before running xsl transformation on it due to what I call bad characters in the data. I have as an example: str = Replace(str, "&#x19;", ".") str =...
4
by: Jon | last post by:
Hi, I used XslCompiledTransform with the following Xsl file. The <xsl:text disable-output-escaping="yes"does not work when using XslCompiledTransform to do the trnasform (namely the output...
3
by: tuka | last post by:
Hi All, Is there a way to temporarily suspend the use of imported libraries in xslt ? To be precise the issue I am trying to resolve is , I have a library imported as <xsl:import...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.