Last change
on this file since 68 was
68,
checked in by cbipsl, 14 years ago
|
commit v1 eccad
|
-
Property svn:executable set to
*
|
File size:
1.1 KB
|
Line | |
---|
1 | package org.medias.eccad.metier; |
---|
2 | |
---|
3 | |
---|
4 | import javax.xml.transform.Source; |
---|
5 | import javax.xml.transform.Transformer; |
---|
6 | import javax.xml.transform.TransformerFactory; |
---|
7 | import javax.xml.transform.stream.StreamSource; |
---|
8 | import javax.xml.transform.stream.StreamResult; |
---|
9 | import java.io.*; |
---|
10 | |
---|
11 | public class TransformXML { |
---|
12 | |
---|
13 | /** |
---|
14 | * Performs an XSLT transformation |
---|
15 | */ |
---|
16 | public String transformation(String xmlContent, String transformeur) throws Exception { |
---|
17 | |
---|
18 | |
---|
19 | File xsltFile = new File(transformeur); |
---|
20 | |
---|
21 | // JAXP reads data using the Source interface |
---|
22 | Source xmlSource = new StreamSource(new StringReader(xmlContent)); |
---|
23 | Source xsltSource = new StreamSource(xsltFile); |
---|
24 | |
---|
25 | // the factory pattern supports different XSLT processors |
---|
26 | TransformerFactory transFact = |
---|
27 | TransformerFactory.newInstance(); |
---|
28 | Transformer trans = transFact.newTransformer(xsltSource); |
---|
29 | |
---|
30 | StringWriter sortie = new StringWriter(); |
---|
31 | |
---|
32 | trans.transform(xmlSource, new StreamResult(sortie)); |
---|
33 | |
---|
34 | return sortie.toString(); |
---|
35 | } |
---|
36 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.