/// <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> /// Create a form for selecting and ordering the columns in a document viewer. /// </summary> /// <param name="dataTransform">The description of how the document is constructed.</param> public ColumnSelector(DataTransform dataTransform) { // IDE Maintained Components. InitializeComponent(); // Initialize the object. this.DataTransform = dataTransform; // These lists contain the available (currently invisible) columns and the displayed columns. this.availableList = new DataTransform.ColumnsNode(); this.displayedList = new DataTransform.ViewNode(); // The available columns are the ones that are not currently part of the view. This basically selects all the columns // that are not in the view. foreach (DataTransform.ColumnNode column in this.DataTransform.Columns) { bool isFound = false; foreach (DataTransform.ColumnReferenceNode columnReferenceNode in this.DataTransform.View) { if (column.ColumnId == columnReferenceNode.ColumnId) { isFound = true; break; } } if (!isFound) { availableList.Add(column); } } // The items in the 'Display' list are the ones already in the view. foreach (DataTransform.ColumnReferenceNode columnReferenceNode in this.DataTransform.View) { displayedList.Add(columnReferenceNode.Column); } // This will synchronize the form with the two lists. DrawListBoxes(); }