|
 |
 |
 |
 |
Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms
of Use |
Trademarks
Article ID: 832757 - Last Review: May 21, 2007 - Revision: 2.4 FIX: A System.Xml.Xsl.XsltException exception occurs when you try to perform an XSLT transformation by using an XSLT style sheet that uses the format-number functionYou create an Extensible Stylesheet Language Transformation (XSLT) style sheet that uses the format-number function. In Microsoft Visual Studio .NET, when you perform an
XSLT transformation that uses this style sheet to try to convert positive
numbers to strings, a System.Xml.Xsl.XsltException exception occurs. To resolve
the problem, download and install a hotfix. To obtain the hotfix, contact
Microsoft Product Support
Services.
You can create an Extensible Stylesheet Language
Transformation (XSLT) style sheet that uses the format-number function. In Microsoft Visual Studio .NET, when you try to
perform an XSLT transformation by using this style sheet to convert positive
numbers to strings, you receive the following error message: An unhandled exception of type 'System.Xml.Xsl.XsltException'
occurred in system.xml.dll If you handle the exception to display the
inner exception and the exception message, you receive the following
output: System.ArgumentException:
NumberGroupSizes Parameter name: Every element in the value array should be
between one and nine, except for the last element, which can be zero. at
System.Globalization.NumberFormatInfo.CheckGroupSize(String propName, Int32[]
groupSize) at System.Xml.Xsl.XsltCompileContext.FormatNumber(Double value,
String formatPattern, String formatName) at
System.Xml.Xsl.FuncFormatNumber.Invoke(XsltContext xsltContext, Object[] args,
XPathNavigator docContext) at
System.Xml.XPath.XsltFunction.InvokeFunction(XPathNavigator qy,
XPathNodeIterator iterator)
Function 'format-number()' has
failed. A supported hotfix is now available from
Microsoft, but it is only intended to correct the problem that is described in
this article. Only apply it to systems that are experiencing this specific
problem. This hotfix may receive additional testing. Therefore, if you are not
severely affected by this problem, we recommend that you wait for the next
service pack that contains this hotfix. To resolve this problem
immediately, contact Microsoft Product Support Services to obtain the hotfix.
For a complete list of Microsoft Product Support Services telephone numbers and
information about support costs, visit the following Microsoft Web site: Note In special cases, charges that are ordinarily incurred for
support calls may be canceled if a Microsoft Support Professional determines
that a specific update will resolve your problem. The usual support costs will
apply to additional support questions and issues that do not qualify for the
specific update in question. The English
version of this hotfix has the file attributes (or later) that are listed in
the following table. The dates and times for these files are listed in
coordinated universal time (UTC). When you view the file information, it is
converted to local time. To find the difference between UTC and local time, use
the Time Zone tab in the Date and Time tool in Control Panel.
Date Time Version Size File name
--------------------------------------------------------------
03-Dec-2003 19:43 1.1.4322.978 1,339,392 System.xml.dll Microsoft
has confirmed that this is a problem in the Microsoft products that are listed
in the "Applies to" section. Steps to reproduce the behaviorCreate a Console Application project- Start Microsoft Visual Studio .NET 2003.
- On the File menu, point to
New, and then click Project.
- Under Project Types, click
Visual C# Projects, and then click Console
Application under Templates.
- In the Name box, type
FormatNumConsole.
- Click OK. By default, the
Class1.cs Code window opens.
Create an XSLT style sheet that uses the format-number function- In Solution Explorer, right-click
FormatNumConsole, point to Add, and then
click Add New Item. The Add New Item -
FormatNumConsole dialog box appears.
- Under Categories, click Local
Project Items.
- Under Templates, click XSLT
File.
- In the Name box, type
format-number.xslt, and then click
Open. The format-number.xslt Code window
opens.
- Replace the existing XML code with the following XML
code to create a template for the presentation of XML data:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="http://support.microsoft.com">
<table>
<xsl:apply-templates />
</table>
</xsl:template>
<xsl:template match="number">
<tr><td><xsl:value-of select="format-number(.,'#,##0;(#,##0)')"/></td></tr>
</xsl:template>
</xsl:stylesheet>
Create an XML file that provides XML data- In Solution Explorer, right-click
FormatNumConsole, point to Add, and then
click Add New Item. The Add New Item -
FormatNumConsole dialog box appears.
- Under Templates, click XML
File.
- In the Name box, type
format-number.xml, and then click Open.
The format-number.xml Code window opens.
- Replace the existing XML code with the following XML
code to provide XML data:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<number>1000</number>
</root>
Try to perform an XSLT transformation by using the XSLT style sheet and the XML file- Switch to the Class1.cs Code window.
- Replace the existing code with the following code to
use the XslTransform class to transform the XML data by using the XSLT style
sheet.
Note In the following code, use the appropriate file paths in the
calls to the XPathDocument constructor and the xsltProcessor.Load method:using System;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.IO;
using System.Text;
namespace FormatNumConsole
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
try
{
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
// Load the XML data that you want to transform.
XPathDocument xmlDoc = new XPathDocument("C:\\FormatNumConsole\\format-number.xml");
// Load the XSLT style sheet that uses the format-number function.
XslTransform xsltProcessor = new XslTransform();
xsltProcessor.Load("C:\\FormatNumConsole\\format-number.xslt");
// Transform the XML data, and then send the output to the console.
xsltProcessor.Transform(xmlDoc,null,sw,null);
}
catch(Exception ex)
{
// Display the inner exception and the exception message.
Console.WriteLine(ex.InnerException.ToString());
Console.WriteLine();
Console.WriteLine(ex.Message);
Console.ReadLine();
}
}
}
} - Build the application, and then run the application.
The output that is mentioned in the "Symptoms" section appears in a console
window.
For additional information, click the
following article numbers to view the articles in the Microsoft Knowledge Base:
824684Â
(http://kbalertz.com/Feedback.aspx?kbNumber=824684/
)
Description of the standard terminology that is used to describe
Microsoft software updates
307494Â
(http://kbalertz.com/Feedback.aspx?kbNumber=307494/
)
How to apply an XSL Transformation to XML for streaming by using Visual C# .NET
For more information, visit the following Microsoft
Developer Network (MSDN) Web sites:
APPLIES TO- Microsoft .NET Framework 1.1
| kbqfe kbhotfixserver kbbug kbformat kbstyle kbxml kbsample kberrmsg kbcode kbfix KB832757 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
|
 |
 |
 |
 |
 |
 |
 |
| |