Posted 14 years ago
by Ken Hanson

Actipro,
I have my xml contained in a string, so I am using SetText to populate the Editor's Document. I found found that I must manualy cause the formater to cause the line breaks and indentation. When the XML document is moderatly large this formating takes an extreem amount of time.
I must be doing something wrong, here is the basics all broken down into a single set of statements.
EditSourceWindow w = new EditSourceWindow();
try
{
//note that the string 's' contains about 300k characters of well formed xml, which works, but is extreemly slow when formating
string s = _designer.CurrentDocument.SaveDocumentToString();
XmlSchemaResolver schemaResolver = new XmlSchemaResolver();
w.xmlEditor.Document.Language.RegisterXmlSchemaResolver(schemaResolver);
XmlTextFormatter formater = (w.xmlEditor.Document.Language as XmlSyntaxLanguage).GetTextFormatter() as XmlTextFormatter;
XmlOutliner outliner = (w.xmlEditor.Document.Language as XmlSyntaxLanguage).GetOutliner() as XmlOutliner;
formater.ElementSpacingMode = XmlElementSpacingMode.RemoveEmptyLines;
formater.AttributeSpacingMode = XmlAttributeSpacingMode.NormalizeWhitespace;
w.xmlEditor.IsOutliningMarginVisible = true;
w.xmlEditor.IsLineNumberMarginVisible = true;
w.xmlEditor.Document.OutliningMode = ActiproSoftware.Windows.Controls.SyntaxEditor.Outlining.OutliningMode.Default;
w.xmlEditor.Document.SetText(s);
TextSnapshotRange tsr = w.xmlEditor.Document.CurrentSnapshot.SnapshotRange;
formater.Format(tsr);
w.xmlEditor.Document.InsertText(TextChangeTypes.AutoFormat, 0, "");
}
catch (Exception ex)
{
}
w.ShowDialog();
Best Regards,
Ken
I have my xml contained in a string, so I am using SetText to populate the Editor's Document. I found found that I must manualy cause the formater to cause the line breaks and indentation. When the XML document is moderatly large this formating takes an extreem amount of time.
I must be doing something wrong, here is the basics all broken down into a single set of statements.
EditSourceWindow w = new EditSourceWindow();
try
{
//note that the string 's' contains about 300k characters of well formed xml, which works, but is extreemly slow when formating
string s = _designer.CurrentDocument.SaveDocumentToString();
XmlSchemaResolver schemaResolver = new XmlSchemaResolver();
w.xmlEditor.Document.Language.RegisterXmlSchemaResolver(schemaResolver);
XmlTextFormatter formater = (w.xmlEditor.Document.Language as XmlSyntaxLanguage).GetTextFormatter() as XmlTextFormatter;
XmlOutliner outliner = (w.xmlEditor.Document.Language as XmlSyntaxLanguage).GetOutliner() as XmlOutliner;
formater.ElementSpacingMode = XmlElementSpacingMode.RemoveEmptyLines;
formater.AttributeSpacingMode = XmlAttributeSpacingMode.NormalizeWhitespace;
w.xmlEditor.IsOutliningMarginVisible = true;
w.xmlEditor.IsLineNumberMarginVisible = true;
w.xmlEditor.Document.OutliningMode = ActiproSoftware.Windows.Controls.SyntaxEditor.Outlining.OutliningMode.Default;
w.xmlEditor.Document.SetText(s);
TextSnapshotRange tsr = w.xmlEditor.Document.CurrentSnapshot.SnapshotRange;
formater.Format(tsr);
w.xmlEditor.Document.InsertText(TextChangeTypes.AutoFormat, 0, "");
}
catch (Exception ex)
{
}
w.ShowDialog();
Best Regards,
Ken