Transformación simple: XML + XSL = XML transformado
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
public class SimpleTransform {
public static void main(String[] args) throws
Exception {
TransformerFactory
tFactory = TransformerFactory.newInstance();
Transformer transformer
= tFactory.newTransformer(new
StreamSource("birds.xsl"));
transformer.transform(new StreamSource("birds.xml"), new
StreamResult(System.out));
}
}
Selección en el fichero XML de la hoja de estilos
XSL como un "Processing Instruction"
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
public class UseStylesheetPI {
public static void main(String[] args) throws
Exception {
String media = null ,
title = null, charset = null;
TransformerFactory tFactory =
TransformerFactory.newInstance();
Source stylesheet =
tFactory.getAssociatedStylesheet(new StreamSource("birds.xml"),
media, title, charset);
Transformer
transformer = tFactory.newTransformer(stylesheet);
transformer.transform(new StreamSource("birds.xml"), new
StreamResult(System.out));
}
}
Hay 3 opiniones. Opina sobre este curso.
| Cursos | Valoración | Alumnos | Vídeo | |
|---|---|---|---|---|
|
Introducción a MSDos Aprende a utilizar este viejo sistema operativo y a implementarlo en funcion con windows. Desde lo más básico hasta lo más avanzado y un poco de hack.... [23/08/06] |
|
7.989 | ||
|
Restaurar fotografías con Photoshop Seguramente en alguna ocasión hemos tenido en nuestras manos alguna fotografía antigua en blanco y negro con algún tipo de deterioro por el paso del tiempo. En e... [26/01/05] |
|
54.931 | ||
|
Procesamiento de datos con Oracle Curso para aprender desde qué son los datos hasta cómo se transforman en información con la ayuda de un gestor de base de datos como Oracle. Disfruta de las herramientas ... [24/02/06] |
|
4.017 | ||
Publicar en
del.icio.us
digg
meneame