*** empty log message ***
[mir.git] / source / mir / misc / XmlSaxonStyler.java
1 package mir.misc;
2
3 import java.io.InputStream;
4 import java.io.IOException;
5 import java.io.OutputStream;
6 import org.xml.sax.SAXException;
7 import com.icl.saxon.trax.Transformer;
8 import com.icl.saxon.trax.Templates;
9 import com.icl.saxon.trax.Result;
10 import com.icl.saxon.PreparedStyleSheet;
11 import org.xml.sax.InputSource;
12
13 /**
14  * Title:        XmlSaxonStyler
15  * Description:  Implement XmlStyler
16  * Copyright:    Copyright (c) 2001
17  * Company:      Indymedia
18  * @author       idfx
19  * @version 1.0
20  */
21
22 public class XmlSaxonStyler implements XmlStyler{
23
24   private XmlSaxonStyler() {}
25   private static XmlSaxonStyler styler = new XmlSaxonStyler();
26   public static XmlSaxonStyler getInstance(){
27     return styler;
28   }
29
30   public void style( String styleKey, InputStream is, OutputStream os )
31     throws SAXException {
32
33     Templates styleSheet = XslStyleCache.getPreparedStyleSheet( styleKey );
34     Transformer transformer = styleSheet.newTransformer();
35     transformer.transform( new InputSource( is ), new Result( os ) );
36   }
37
38   public void style( Transformer transformer, InputStream is, OutputStream os )
39     throws SAXException {
40
41     transformer.transform( new InputSource( is ), new Result( os ) );
42   }
43 }