/// <summary> /// Creates a writer to translate an incoming XSL stylesheet into a data structure. /// </summary> public XmlStylesheetWriter(Stylesheet stylesheet) { // Initialize the object; this.stylesheet = stylesheet; // This determines how to handle each of the incoming tokens parsed out of the XML stream. this.tokenHandlerDictionary = new Dictionary <Token, TokenHandler>(); // This stack holds the current state of parsing the XSL language elements. It is needed to build a tree of these // structures that is roughly the same as the incoming XSL document. The stack structure is required because the // parsing can recursively dig down into the data structures, the unwind back up the tree before reading more child // elements. The stack structure keeps track of how far down into the tree the parsing has gone. this.nodeStack = new Stack <Node>(); this.nodeStack.Push(new RootNode()); // This will create a lexical analyzer for the XSL Stylesheets and installs handlers for each of the tokens read from // the XML stream as it parses the stylesheet. this.lexicon = new Lexicon(); this.tokenHandlerDictionary.Add(Token.Alignment, new TokenHandler(ParseAlignment)); this.tokenHandlerDictionary.Add(Token.Animation, new TokenHandler(ParseAnimation)); this.tokenHandlerDictionary.Add(Token.ApplyTemplate, new TokenHandler(ParseApplyTemplate)); this.tokenHandlerDictionary.Add(Token.Attribute, new TokenHandler(ParseAttribute)); this.tokenHandlerDictionary.Add(Token.Border, new TokenHandler(ParseBorder)); this.tokenHandlerDictionary.Add(Token.Borders, new TokenHandler(ParseBorders)); this.tokenHandlerDictionary.Add(Token.Cell, new TokenHandler(ParseCell)); this.tokenHandlerDictionary.Add(Token.Choose, new TokenHandler(ParseChoose)); this.tokenHandlerDictionary.Add(Token.Column, new TokenHandler(ParseColumn)); this.tokenHandlerDictionary.Add(Token.Columns, new TokenHandler(ParseColumns)); this.tokenHandlerDictionary.Add(Token.Constraint, new TokenHandler(ParseConstraint)); this.tokenHandlerDictionary.Add(Token.Constraints, new TokenHandler(ParseConstraints)); this.tokenHandlerDictionary.Add(Token.ColumnReference, new TokenHandler(ParseColumnReference)); this.tokenHandlerDictionary.Add(Token.Delete, new TokenHandler(ParseDelete)); this.tokenHandlerDictionary.Add(Token.View, new TokenHandler(ParseView)); this.tokenHandlerDictionary.Add(Token.Font, new TokenHandler(ParseFont)); this.tokenHandlerDictionary.Add(Token.Fragment, new TokenHandler(ParseFragment)); this.tokenHandlerDictionary.Add(Token.If, new TokenHandler(ParseIf)); this.tokenHandlerDictionary.Add(Token.Insert, new TokenHandler(ParseInsert)); this.tokenHandlerDictionary.Add(Token.Interior, new TokenHandler(ParseInterior)); this.tokenHandlerDictionary.Add(Token.NumberFormat, new TokenHandler(ParseNumberFormat)); this.tokenHandlerDictionary.Add(Token.Otherwise, new TokenHandler(ParseOtherwise)); this.tokenHandlerDictionary.Add(Token.Protection, new TokenHandler(ParseProtection)); this.tokenHandlerDictionary.Add(Token.Row, new TokenHandler(ParseRow)); this.tokenHandlerDictionary.Add(Token.Style, new TokenHandler(ParseStyle)); this.tokenHandlerDictionary.Add(Token.Styles, new TokenHandler(ParseStyles)); this.tokenHandlerDictionary.Add(Token.Stylesheet, new TokenHandler(ParseStylesheet)); this.tokenHandlerDictionary.Add(Token.Table, new TokenHandler(ParseTable)); this.tokenHandlerDictionary.Add(Token.Template, new TokenHandler(ParseTemplate)); this.tokenHandlerDictionary.Add(Token.Update, new TokenHandler(ParseUpdate)); this.tokenHandlerDictionary.Add(Token.ValueOf, new TokenHandler(ParseValueOf)); this.tokenHandlerDictionary.Add(Token.Variable, new TokenHandler(ParseVariable)); this.tokenHandlerDictionary.Add(Token.Sort, new TokenHandler(ParseSort)); this.tokenHandlerDictionary.Add(Token.SortColumn, new TokenHandler(ParseSortColumn)); this.tokenHandlerDictionary.Add(Token.When, new TokenHandler(ParseWhen)); this.tokenHandlerDictionary.Add(Token.Document, new TokenHandler(ParseDocument)); }
/// <summary> /// Creates a writer to translate an incoming XSL stylesheet into a data structure. /// </summary> public XmlDataTransformWriter(DataTransform dataTransform) { // Initialize the object; this.dataTransform = dataTransform; // This determines how to handle each of the incoming tokens parsed out of the XML stream. this.tokenHandlerDictionary = new Dictionary <Token, TokenHandler>(); // This stack holds the current state of parsing the XSL language elements. It is needed to build a tree of these // structures that is roughly the same as the incoming XSL document. The stack structure is required because the // parsing can recursively dig down into the data structures, the unwind back up the tree before reading more child // elements. The stack structure keeps track of how far down into the tree the parsing has gone. this.nodeStack = new Stack <Node>(); this.nodeStack.Push(new RootNode()); // This will create a lexical analyzer for the XSL DataTransforms and installs handlers for each of the tokens read from // the XML stream as it parses the stylesheet. this.lexicon = new Lexicon(); this.tokenHandlerDictionary.Add(Token.Animation, new TokenHandler(ParseAnimation)); this.tokenHandlerDictionary.Add(Token.ApplyTemplate, new TokenHandler(ParseApplyTemplate)); this.tokenHandlerDictionary.Add(Token.BottomBorder, new TokenHandler(ParseBottomBorder)); this.tokenHandlerDictionary.Add(Token.LeftBorder, new TokenHandler(ParseLeftBorder)); this.tokenHandlerDictionary.Add(Token.RightBorder, new TokenHandler(ParseRightBorder)); this.tokenHandlerDictionary.Add(Token.TopBorder, new TokenHandler(ParseTopBorder)); this.tokenHandlerDictionary.Add(Token.Tile, new TokenHandler(ParseTile)); this.tokenHandlerDictionary.Add(Token.Column, new TokenHandler(ParseColumn)); this.tokenHandlerDictionary.Add(Token.Columns, new TokenHandler(ParseColumns)); this.tokenHandlerDictionary.Add(Token.ColumnReference, new TokenHandler(ParseColumnReference)); this.tokenHandlerDictionary.Add(Token.Data, new TokenHandler(ParseData)); this.tokenHandlerDictionary.Add(Token.DataTransform, new TokenHandler(ParseDataTransform)); this.tokenHandlerDictionary.Add(Token.View, new TokenHandler(ParseView)); this.tokenHandlerDictionary.Add(Token.Filter, new TokenHandler(ParseFilter)); this.tokenHandlerDictionary.Add(Token.Font, new TokenHandler(ParseFont)); this.tokenHandlerDictionary.Add(Token.FontBrush, new TokenHandler(ParseFontBrush)); this.tokenHandlerDictionary.Add(Token.Image, new TokenHandler(ParseImage)); this.tokenHandlerDictionary.Add(Token.InteriorBrush, new TokenHandler(ParseInteriorBrush)); this.tokenHandlerDictionary.Add(Token.Locks, new TokenHandler(ParseLocks)); this.tokenHandlerDictionary.Add(Token.Lock, new TokenHandler(ParseLock)); this.tokenHandlerDictionary.Add(Token.NumberFormat, new TokenHandler(ParseNumberFormat)); this.tokenHandlerDictionary.Add(Token.Protection, new TokenHandler(ParseProtection)); this.tokenHandlerDictionary.Add(Token.Row, new TokenHandler(ParseRow)); this.tokenHandlerDictionary.Add(Token.Style, new TokenHandler(ParseStyle)); this.tokenHandlerDictionary.Add(Token.StyleId, new TokenHandler(ParseStyleId)); this.tokenHandlerDictionary.Add(Token.Styles, new TokenHandler(ParseStyles)); this.tokenHandlerDictionary.Add(Token.Template, new TokenHandler(ParseTemplate)); this.tokenHandlerDictionary.Add(Token.Scale, new TokenHandler(ParseScale)); this.tokenHandlerDictionary.Add(Token.Split, new TokenHandler(ParseSplit)); this.tokenHandlerDictionary.Add(Token.Scratch, new TokenHandler(ParseScratch)); this.tokenHandlerDictionary.Add(Token.StringFormat, new TokenHandler(ParseStringFormat)); this.tokenHandlerDictionary.Add(Token.Sort, new TokenHandler(ParseSort)); this.tokenHandlerDictionary.Add(Token.SortColumn, new TokenHandler(ParseSortColumn)); this.tokenHandlerDictionary.Add(Token.Source, new TokenHandler(ParseSource)); this.tokenHandlerDictionary.Add(Token.Variable, new TokenHandler(ParseVariable)); }
/// <summary> /// Creates a writer to translate an incoming XSL stylesheet into a data structure. /// </summary> public StylesheetWriter(Stylesheet stylesheet) { // Initialize the object; this.stylesheet = stylesheet; // This holds a stack of the tokens as they're parsed from the incoming XSL stylesheet. this.driverStack = new Stack <Driver>(); // This stack holds the current state of parsing the XSL language elements. It is needed to build a tree of these // structures that is roughly the same as the incoming XSL document. The stack structure is required because the // parsing can recursively dig down into the data structures, the unwind back up the tree before reading more child // elements. The stack structure keeps track of how far down into the tree the parsing has gone. this.nodeStack = new Stack <Node>(); // This will create a lexical analyzer for the XSL Stylesheets and installs handlers for each of the tokens read from // the XML stream as it parses the stylesheet. this.lexicon = new Lexicon(); this.lexicon.InstallHandlers(Token.Alignment, new TokenHandler(this.ParseAlignmentStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Animation, new TokenHandler(this.ParseAnimationStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.ApplyTemplate, new TokenHandler(this.ParseApplyTemplateStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Attribute, new TokenHandler(this.ParseXslElementStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Border, new TokenHandler(this.ParseBorderStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Borders, new TokenHandler(this.ParseBordersStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Cell, new TokenHandler(this.ParseCellStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Choose, new TokenHandler(this.ParseXslElementStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Column, new TokenHandler(this.ParseColumnStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Columns, new TokenHandler(this.ParseColumnsStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.ComponentOptions, new TokenHandler(this.ParseXslElementStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Constraint, new TokenHandler(this.ParseConstraintStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.ConstraintColumn, new TokenHandler(this.ParseConstraintColumnStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Data, new TokenHandler(this.ParseDataStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Delete, new TokenHandler(this.ParseDeleteStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Display, new TokenHandler(this.ParseDisplayStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.DoNotSelectRows, new TokenHandler(this.ParseDoNotSelectRowsStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Font, new TokenHandler(this.ParseFontStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Fragment, new TokenHandler(this.ParseFragmentStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.HideOfficeLogo, new TokenHandler(this.ParseXslElementStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.If, new TokenHandler(this.ParseXslElementStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Insert, new TokenHandler(this.ParseInsertStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Interior, new TokenHandler(this.ParseInteriorStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.NumberFormat, new TokenHandler(this.ParseNumberFormatStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Otherwise, new TokenHandler(this.ParseXslElementStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Printer, new TokenHandler(this.ParsePrinterStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Protection, new TokenHandler(this.ParseProtectionStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Row, new TokenHandler(this.ParseRowStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Style, new TokenHandler(this.ParseStyleStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Styles, new TokenHandler(this.ParseStylesStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Stylesheet, new TokenHandler(this.ParseStylesheetStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Table, new TokenHandler(this.ParseTableStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Template, new TokenHandler(this.ParseTemplateStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Toolbar, new TokenHandler(this.ParseXslElementStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Update, new TokenHandler(this.ParseUpdateStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.ValueOf, new TokenHandler(this.ParseXslElementStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Variable, new TokenHandler(this.ParseXslElementStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.View, new TokenHandler(this.ParseViewStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.ViewColumn, new TokenHandler(this.ParseViewColumnStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.When, new TokenHandler(this.ParseXslElementStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Workbook, new TokenHandler(this.ParseWorkbookStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.Worksheet, new TokenHandler(this.ParseWorksheetStart), new TokenHandler(this.PopNodeStack)); this.lexicon.InstallHandlers(Token.WorksheetOptions, new TokenHandler(this.ParseWorksheetOptionsStart), new TokenHandler(this.PopNodeStack)); }