"[XaToA]" <granbilbao_NOSPAM_@latinmail.com>, Sat, 26 Jul 2003 15:35:43
+0200:
> Hello.
> from one select to one database i extract one string in XML format.
> for example this:
>
> String cadenaXML="<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"+
> "<registros>\n
> <registro>\n<id>2</id>\n<nombremaquina>nombre1</nombremaquina>\n"+
> "<idcurso>56</idcurso>\n<nombrecursocastellano>curso cast
> 1</nombrecursocastellano>\n"+
> "<nombrecursoingles>curso ing 1</nombrecursoingles>\n</registro>\n"+
> "<registro>\n<id>22</id>\n<nombremaquina>nombre2</nombremaquina>\n<idcurso>2
> 23</idcurso>\n"+
> "<nombrecursocastellano>curso cast
> 2</nombrecursocastellano>\n<nombrecursoingles>curso ing
> 2</nombrecursoingles>\n"+
> </registro>\n</registros>";
>
> i want to parse this with jdom (or xerces) and to conver to this:
>
> 2 nombre1 56 curso cast 1 curso ing 1
> 22 nombre2 22 curso cast 2 curso ing 2
>
> Can you help me please?
> i am working in this problem during 3 days and i cannot solve it.
> I dont work with jdom and i am readin the doc but i dont get to solve this
> problem.
Read the part about XSL transformations:
http://java.sun.com/webservices/tutorial.html
Use a stylesheet like this (it's not sufficient to get it totally like you
want it to, but it should get things started; i really hate xsl syntax.)
Be sure to set the parameters of the transformation to the correct
encoding..
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns

sl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl

utput encoding="UTF-8" method="html" omit-xml-declaration="yes"/>
<xsl:template match="registros"><xsl:apply-templates select="registro"></xsl:apply-templates></xsl:template>
<xsl:template match="registro"><xsl:apply-templates select="id|nombremaquina|idcurso|nombrecursocastel lano|nombrecursoingles"></xsl:apply-templates><xsl:text>
</xsl:text></xsl:template>
<xsl:template match="id|nombremaquina|idcurso|nombrecursocastell ano|nombrecursoingles"><xsl:text> </xsl:text><xsl:value-of select="text()"/><xsl:text> </xsl:text></xsl:template>
</xsl:stylesheet>
greets
Bhun.