← Back to team overview

kolibri-discuss team mailing list archive

Re: Coordinate XmlGenerator and XslTransformer

 


On Dec 17, 2008, at 11:03 AM, Anders Steinlein wrote:

While going through the framework hunting for trigger_error()s to be
replaced by exceptions, one thing struck me in XslTransformer as it
relates to XmlGenerator in XsltResult. XslTransformer's addXml() method
currently only accepts XML as a string, which is loaded into a
DOMDocument internally. This seems rather odd considering we use a
DOMDucument internally in XmlGenerator as well, before it is dumped to a string. I suggest this should be improved during the current rewrite of
XmlGenerator, to support, say, buildToDom() and buildToString(), with
matching methods in XslTransformer.

Good idea to brush up on XslTransformer as well. I've already changed XmlGenerator's public interface, which no longer uses a build() method. It's been replaced by a getXml() method which returns an XML string, and thus a similar getDom() method would be easy to provide.

It's definitely unnecessary to jump between DOMDocument -> XML string -> DOMDocument to use the output of XmlGenerator in XslTransformer. Since they're both core utility classes I'd suggest XslTransformer supports working directly with XmlGenerator (ie. using getDom())?

Another "weirdness" in XslTransformer as it stands now is that the addXml() method really should be called setXml() considering how it works right now. You can't incrementally add XML strings to XslTransformer as it will just overwrite the previous XML. I guess some improvement on this could be done as well, using the internal DOMDocument more properly.

--
Frode



Follow ups

References