views:

100

answers:

3

Here is links to my files

XML

XSLT

Include XSLT

Hi

I am transforming xml into html. My xml file is about 10kb big and my xslt 70kb and output html about 10kb big.

Transformer xformer = StylesheetCache.newTransformer(templateFile);
xformer.transform(new DOMSource(outlineDoc),new StreamResult(out));

The creating of the transformer takes about 10s to create thats why i created cache that bring it down to 300ms if its cached. The transform line takes 3s to execute. Now is this long. I have written similar transforms on windows mobile and it execution time is about <=1s

I changed the TransformerFactory to Saxon but the result was about the same.

thanks

A: 

Are you experiencing such delays on each transformation? I've noticed that when it takes a while for Android to load the third-party libraries into the process. The exact time depends on the library size. For example loading joda-time takes approximately 3 seconds.

nixau
Yes its after everything is loaded. At the transform line of code
Pintac
A: 

You problem is with use of DOMSource, don't use it if at all possible. Saxon specifically has much worse performance compared to using a streaming source or SAX source -- this because it builds its own highly optimized (for xslt use) tree ("tiny tree"). There is a work-around to this problem as well as full explanation at: http://saxonica.blogharbor.com/blog/_archives/2007/3/31/2848654.html.

But even if you were using Xalan (JDK default), it makes sense to use raw input and not build intermediate DOM structure; XSLT processors can build optimal in-memory representation themselves and often more efficiently.

StaxMan
hiI dont have AugmentedSource in android. I changed the domsource to a streamsource and a saxsource but the processing time still stayed the same.
Pintac
Ok, that is unexpected. And you are sure you are using Saxon, not default implementation (Xalan)? For me difference was very noticeable, time went down by 50% or so when I made changes, but this was on regular Java SE not Android. This does sound like problem is with stylesheet itself, not xslt processor.
StaxMan
hi. Yip i use SAXTransformerFactory.newinstance(). I suspected it mite be the xslt but if i run the exact same xslt on msxml xslt transforner is milliseconds
Pintac
Yeah; creating new transformer factory is wasteful, but that'd just add a millisecond or two -- your timing sounds very much worse, which is why I think it's the stylesheet that does something very slow (sorry didn't yet look at linked to files so no idea what)
StaxMan
A: 

Hi

I found the problem... I think i need to kick myself. I was at home playing with my phone so i decided to play with the app a bit. and all of a sudden the init load was like 1s and subsequent calls like 500ms. So at this point i was stumped. i so pulled out my laptop plugged my phone in and debugged and all of a suddend it was 12s again. i was the freaking IDE. as soon as i run it through ecclipse it slows down to 12s.

:-\

Pintac