Groups | Blog | Home
all groups > dotnet xml > july 2007 >

dotnet xml : performance: StringBuilder vs StringBuilder & XSLT


SpaceMarine
7/23/2007 8:45:54 AM
hello,

im having a discussion w/ one of my associates, and we're are trying
to get a consensus on a possible performance scenario. we're working
a/ 3-rd party component that produces PDFs using "XML-FO", a verbose
description & layout doc. it can accept either:

1) a complete, verbose XML-FO doc
2) data-only XML, plus an XSLT doc to produce valid verbose XML-FO,
which it transforms

.....we have our source data in memory as many collection objects. thus
we need to convert it into something usable (either XML-FO, or XML).
there are two options:

1) iterate thru the collections, using a StringBuilder to build the
final verbose doc in code. lots of presentation tags, which is sorta a
bummer cuz its all static strings if using StringBuilder.

2) iterate thru the collections, using a StringBuilder to build a
smaller data-only XML, then use an XSLT doc to perform transform for
final verbose doc. designing the XSLT in an XML-smart editor is a
plus.

....i know its sorta a vague question w/o a lot of detail, but in
general what do you think would be faster? heavier string
concatenation, or less concats + a transform?


for maintenance & readability using an XSLT doc may be preferred, even
if the performance differences are negligible. but we are curious
about the hypothetical speed differences of the two, if any.

what are you thoughts?


thanks,
sm
Bjoern Hoehrmann
7/23/2007 10:55:23 PM
* SpaceMarine wrote in microsoft.public.dotnet.xml:
[quoted text, click to view]

The latest versions of the .NET Framework should have very fast XSLT
processors, while there are many variables you have not mentioned, I
think it's unlikely that it will be any slower. I would not recommend
to use string concatenation to build XML documents through, there are
many better ways to do that in the framework.
--
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
SpaceMarine
7/24/2007 7:37:10 AM
[quoted text, click to view]

what other ways are there? theres the XmlDocument dom object of
course. however, some critics feel that loading up the entire DOM is
too heavy/slow just for for building a a new doc. im just curious; i
have no strong feelings either way.


thanks,
sm
Martin Honnen
7/24/2007 4:46:15 PM
[quoted text, click to view]

Use XmlWriter to construct your XML.

--

Martin Honnen --- MVP XML
AddThis Social Bookmark Button