ABC分类法
ABC分类法,是一种根据帕累托最优原则设计的分类方法,多用于库存分析。
ABC分类法能够对产品进行区别和分类,并能反映出每类产品的价值对库存、销售、成本等总价值的影响。
库存管理(又称为存货管理)的实际例子:
- "A类"产品: 这类产品的价值占库存总价值的80%,而其数量只占库存总产品数量的20%
- "B类"产品: 这类产品的价值占库存总价值的15%,而其数量占库存总产品数量的30%
- "C类"产品: 这类产品的价值只占库存总价值的5%,而其数量占库存总产品数量的50%
| Data Quality | Issue | Sample Data Problem |
| Standard | Are data elements consistently defined and understood? | Gender code =M,F,U in one system and Gender code = 0, 1, 2 in another system |
| Complete | Is all necessary data present? | 20% of customers’ last name is blank, 50% of zip-codes are 99999 |
| Accurate | Does the data accurately represent reality or a verifiable source? | A supplier is listed as ‘Active’ but went out of business six years ago |
| Valid | Do data values fall within acceptable ranges | Salary values should be between 60,000 – 12,000 |
| Unique | Data appears several times | Both John Ryan and Jack Ryan appear in the system – are they the same person? |
DQS…
1: // strips illegal Xml characters:
2: static public String XmlEncode(String S)
3: {
4: if (S == null)
5: {
6: return null;
7: }
8: S = Regex.Replace(S, @"[^\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD]", "", RegexOptions.Compiled);
9: return XmlEncodeAsIs(S);
10: }
11:
12: // leaves whatever data is there, and just XmlEncodes it:
13: static public String XmlEncodeAsIs(String S)
14: {
15: if (S == null)
16: {
17: return null;
18: }
19: StringBuilder sTmp = new StringBuilder();
20: using (StringWriter sw = new StringWriter())
21: {
22: using (XmlTextWriter xwr = new XmlTextWriter(sw))
23: {
24: xwr.WriteString(S);
25: sTmp.Append(sw.ToString());
26: xwr.Flush();
27: xwr.Close();
28: }
29: sw.Close();
30: }
31: return sTmp.ToString();
32: }
XSLT is a transformation language for XML. It allows server systems to transform the source XML tree into a more suitable form for clients. XSLT uses node patterns to match against templates to perform its transformations. Though it makes complex transformations relatively simple there are some situations where we might have to use some custom classes.
Some of the situations where we might need to extend XSLT are:
1) Call custom business logic
2) Perform different actions depending on Permissions
3) Perform complex formatting for dates, strings etc
4) Or even call a webservice!!
Steps to extend XSLT
1) Create the custom object to use from within XSLT(in C#)
CustomDate custDate = new CustomDate();
2) Provide a custom namespace declaration for the custom class within XSLTs namespace declaration(in XSLT file)
<xsl:transform
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:myCustDate="urn:custDate">
3) Pass an instance of the custom object to XSLT, with the same namespace as in last step(in C#)
xslArgs.AddExtensionObject("urn:custDate", custDate) ;
4) Use the object from within XSLT(in XSLT file)
<xsl:value-of select="myCustDate:GetDateDiff(./joiningdate)"/>
Sample Code
For our example let us assume we have a XSLT sheet where we need to manipulate dates. We need to show the number of days the employee has been with the company. Since XSLT has no native date manipulation functions, let us use an extension object for our task.
1: using System ;
2: using System.IO ;
3: using System.Xml ;
4: using System.Xml.Xsl ;
5: using System.Xml.XPath ;
6:
7: public class XsltExtension{
8:
9: public static void Main(string[] args){
10: if (args.Length == 2){
11: Transform(args[0], args[1]) ;
12: }else{
13: PrintUsage() ;
14: }
15: }
16:
17: public static void Transform(string sXmlPath, string sXslPath){
18: try{
19: //load the Xml doc
20: XPathDocument myXPathDoc = new XPathDocument(sXmlPath) ;
21: XslTransform myXslTrans = new XslTransform() ;
22:
23: //load the Xsl
24: myXslTrans.Load(sXslPath) ;
25: XsltArgumentList xslArgs = new XsltArgumentList() ;
26:
27: //create custom object
28: CustomDate custDate = new CustomDate() ;
29:
30: //pass an instance of the custom object
31: xslArgs.AddExtensionObject("urn:custDate", custDate) ;
32:
33: //create the output stream
34: XmlTextWriter myWriter = new XmlTextWriter("extendXSLT.html", null) ;
35:
36: //pass the args,do the actual transform of Xml
37: myXslTrans.Transform(myXPathDoc,xslArgs, myWriter) ;
38:
39: myWriter.Close() ;
40:
41: }catch(Exception e){
42:
43: Console.WriteLine("Exception: {0}", e.ToString());
44: }
45:
46: }
47:
48: public static void PrintUsage(){
49: Console.WriteLine("Usage: XsltExtension.exe <xml path> >xsl path<") ;
50: }
51:
52: }
53:
54: //our custom class
55: public class CustomDate{
56:
57: //function that gets called from XSLT
58: public string GetDateDiff(string xslDate){
59:
60: DateTime dtDOB = DateTime.ParseExact(xslDate, "dd/MM/yyyy", null); //DateTime.Parse(xslDate);
61: DateTime dtNow = DateTime.Today ;
62: TimeSpan tsAge = dtNow.Subtract(dtDOB);
63: return tsAge.Days.ToString() ;
64: }
65: }
Compile this code and use the provided members.xml and memberdisplay.xsl to run this console application. You should see a extendXSLT.html file within the same folder. Open this file and notice that our class CustomDate has been called to calculate the number of days the employee has been in the company.
Summary :
XSLT is a powerful transformation language for XML, however using extension objects in .NET and C# should ensure that we could easily accomplish what would be impossible or hard with XSLT alone.
-------------------------------------------------------------
Members.xml:
<root> <member> <name>Employee1</name> <joiningdate>01/01/1970</joiningdate> <role>CTO</role> </member> <member> <name>Employee2</name> <joiningdate>24/07/1978</joiningdate> <role>Web Developer</role> </member> <member> <name>Employee3</name> <joiningdate>15/12/1980</joiningdate> <role>Tester</role> </member> </root>
MemberDisplay.xslt:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:myCustDate="urn:custDate"> <xsl:output method="html" omit-xml-declaration="yes" /> <xsl:template match="/"> <html> <head> <style> TABLE.tblMaster { border-style: solid; border-width: 1px 1px 1px 1px; border-style: solid; border-color: #99CCCC; padding: 4px 6px; text-align: left; font-family:Tahoma,Arial; font-size:9pt; } TD.tdHeader { FONT-WEIGHT: bolder; FONT-FAMILY: Arial; BACKGROUND-COLOR: lightgrey; TEXT-ALIGN: center } </style> </head> <body> <table width="50%" class="tblMaster"> <tr > <td class="tdHeader">Employee</td> <td class="tdHeader">Join date</td> <td class="tdHeader">Days in company</td> <td class="tdHeader">Role</td> </tr> <xsl:for-each select="/root/member"> <tr > <td> <xsl:value-of select="./name"/> </td> <td> <xsl:value-of select="./joiningdate"/> </td> <td> <xsl:value-of select="myCustDate:GetDateDiff(./joiningdate)"/> </td> <td> <xsl:value-of select="./role"/> </td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
Cannot find some counter categories, just like BizTalk Message Agent
You’d make sure the host instance is started, if it is stopped, some counters would not be shown in the performance monitor.
