PRB Convert XML FILE

Here should go questions about transforming XML with XSLT and FOP.
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

PRB Convert XML FILE

Post by Le Basque »

Hi,

I have an XML file :

Code: Select all


<personnes>
<personne>
<name>XXXX</name>
<adress>YYYYY<nl/>ZZZZZZ<nl/>AAAAA</adress>
</personne>
</personnes>
I want to get (I want to make a table)
...
<row>
<entry rowsep="0" align="left"><para><p>XXXX</p></para></entry>
<entry>
<para><p>YYYYY</p></para>
<para><p>ZZZZZZ</p></para>
<para><p>AAAAA</p></para>
</entry>
</row>
...
My XSLT code :

Code: Select all


<xsl:template match="personne">	
<row><xsl:apply-templates /></row>
</xsl:template>
<xsl:template match="name">
<entry rowsep="0" align="left">
<para><p><xsl:value-of select="."/></p></para>
</entry>
</xsl:template>
<xsl:template match="adress">
<entry>
<para><p><xsl:value-of select="."/></p></para>
<xsl:apply-templates />
</entry>
</xsl:template>
<xsl:template match="nl">
<xsl:text></p></para><para><p></xsl:text>
</xsl:template>
thank you for help
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

Re: PRB Convert XML FILE

Post by Le Basque »

My result is not OK i obtains

Code: Select all


...
<row>
<entry rowsep="0" align="left"><para><p>XXXX</p></para></entry>
<entry>
<para><p>YYYYY ZZZZZZ AAAAA</p></para>
</entry>
</row>
...
adrian
Posts: 2854
Joined: Tue May 17, 2005 4:01 pm

Re: PRB Convert XML FILE

Post by adrian »

Hi,

I've changed the address template to use each individual text node and just ignored the separating element (nl).

Code: Select all


    <xsl:template match="adress">
<entry>
<xsl:for-each select="text()">
<para><p><xsl:value-of select="."/></p></para>
</xsl:for-each>
</entry>
</xsl:template>
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

Re: PRB Convert XML FILE

Post by Le Basque »

Thank you is ok

best regards
Post Reply