You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Manuel Ottaviano <co...@lst.tfo.upm.es> on 2006/09/06 18:27:46 UTC

XSLT table formatting problem

*Hello cocoon users , I've a problem with a trasformation of an XML file.
This  is the XML file, generated by a pipeline process:*

<page xmlns:xlink="http://www.w3.org/1999/xlink" 
xmlns:i18n="http://apache.org/cocoon/i18n/2.1" >
<program>program</program>
   <data>
    <product>Hearth Failure Management</product>
    <error_code>200</error_code>
    <command>List of Patient</command>
    <rows>
        <row>
            <status>Alert!</status>
            <surname>Rodriguez</surname>
            <name>Manuel</name>
            <chn>1234556789</chn>
            <age>60</age>
            <gender>F</gender>
            <lastSeen>lastSeen</lastSeen>
            <patientID>1563</patientID>
        </row>
        <row>
            ...
          .... [much more data....]
          .....
        </row>

    </rows>
</data>

</page>

*I've created a test stylesheet to generate a table , like the following:*

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/page">
  <html>
  <body>
    <h2>List of Patient</h2>
    <table border="1">
    <tr bgcolor="#9acd32">
      <th align="left">Status</th>
      <th align="left">Surname</th>
         </tr>
        <xsl:for-each select="/page/data/rows/row">
    <tr>
      <td><xsl:value-of select="status"/></td>
      <td><xsl:value-of select="surname"/></td>
    </tr>
    </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>

*If  I test with a browser or with XML-spy  I obtain a table, but if I 
insert the stylesheet inside the pipeline, as a transformer  it doesn't 
work....... only can be seen  the table header....

*<html>
    <body>
<h2>List of Patient</h2>
   <table border="1">
 <tr bgcolor="#9acd32">
<th align="left">Status</th>
<th align="left">Surname</th>
</tr>
</table>
</body>
</html>*
*



*I'm a bit lost....

ANY suggestion??

thanks very much.

manuel ottaviano
*

Re: XSLT table formatting problem

Posted by Lars Huttar <la...@sil.org>.
On 9/6/2006 7:35 PM, Tony Edwards wrote:
> Try this:
> <xsl:for-each select="data/rows/row">
> You're already at the /page element when you call the for-each so it 
> can't find a /page child.
> (I don't know why it would work in XML-Spy, maybe its more lenient??)
>
> See how you go.
>
> Regards
> Tony
>
Tony, "/page" does not try to select a child element. Any XPath 
expression starting with "/" starts from the root node.
So this expression should work, regardless of what XSLT processor you 
use, and regardless of the context node.
> Manuel Ottaviano wrote:
>> *Hello cocoon users , I've a problem with a trasformation of an XML 
>> file.
>> This  is the XML file, generated by a pipeline process:*
>>
>> <page xmlns:xlink="http://www.w3.org/1999/xlink" 
>> xmlns:i18n="http://apache.org/cocoon/i18n/2.1" >
>> <program>program</program>
>>    <data>
>>     <product>Hearth Failure Management</product>
>>     <error_code>200</error_code>
>>     <command>List of Patient</command>
>>     <rows>
>>         <row>
>>             <status>Alert!</status>
>>             <surname>Rodriguez</surname>
>>             <name>Manuel</name>
>>             <chn>1234556789</chn>
>>             <age>60</age>
>>             <gender>F</gender>
>>             <lastSeen>lastSeen</lastSeen>
>>             <patientID>1563</patientID>
>>         </row>
>>         <row>
>>             ...
>>           .... [much more data....]
>>           .....
>>         </row>
>>
>>     </rows>
>> </data>
>>
>> </page>
>>
>> *I've created a test stylesheet to generate a table , like the 
>> following:*
>>
>> <xsl:stylesheet version="1.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>>
>> <xsl:template match="/page">
>>   <html>
>>   <body>
>>     <h2>List of Patient</h2>
>>     <table border="1">
>>     <tr bgcolor="#9acd32">
>>       <th align="left">Status</th>
>>       <th align="left">Surname</th>
>>          </tr>
>>         <xsl:for-each select="/page/data/rows/row">
>>     <tr>
>>       <td><xsl:value-of select="status"/></td>
>>       <td><xsl:value-of select="surname"/></td>
>>     </tr>
>>     </xsl:for-each>
>>     </table>
>>   </body>
>>   </html>
>> </xsl:template>
>>
>> </xsl:stylesheet>
>>
>> *If  I test with a browser or with XML-spy  I obtain a table, but if 
>> I insert the stylesheet inside the pipeline, as a transformer  it 
>> doesn't work....... only can be seen  the table header....
>>
>> *<html>
>>     <body>
>> <h2>List of Patient</h2>
>>    <table border="1">
>>  <tr bgcolor="#9acd32">
>> <th align="left">Status</th>
>> <th align="left">Surname</th>
>> </tr>
>> </table>
>> </body>
>> </html>*
>> *
>>
>>
>>
>> *I'm a bit lost....
>>
>> ANY suggestion??
>>
>> thanks very much.
>>
>> manuel ottaviano
>> *
That is strange... looks right to me.
I tried it in the Oxygen debugger and it produced a table with multiple 
rows.

I would double-check that the input to the stylesheet is really what you 
think it is...

Lars


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: XSLT table formatting problem

Posted by Tony Edwards <te...@civica.com.au>.
Try this:
<xsl:for-each select="data/rows/row">
You're already at the /page element when you call the for-each so it can't find a /page child.
(I don't know why it would work in XML-Spy, maybe its more lenient??)

See how you go.

Regards
Tony

Manuel Ottaviano wrote:
> *Hello cocoon users , I've a problem with a trasformation of an XML file.
> This  is the XML file, generated by a pipeline process:*
> 
> <page xmlns:xlink="http://www.w3.org/1999/xlink" 
> xmlns:i18n="http://apache.org/cocoon/i18n/2.1" >
> <program>program</program>
>    <data>
>     <product>Hearth Failure Management</product>
>     <error_code>200</error_code>
>     <command>List of Patient</command>
>     <rows>
>         <row>
>             <status>Alert!</status>
>             <surname>Rodriguez</surname>
>             <name>Manuel</name>
>             <chn>1234556789</chn>
>             <age>60</age>
>             <gender>F</gender>
>             <lastSeen>lastSeen</lastSeen>
>             <patientID>1563</patientID>
>         </row>
>         <row>
>             ...
>           .... [much more data....]
>           .....
>         </row>
> 
>     </rows>
> </data>
> 
> </page>
> 
> *I've created a test stylesheet to generate a table , like the following:*
> 
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
> <xsl:template match="/page">
>   <html>
>   <body>
>     <h2>List of Patient</h2>
>     <table border="1">
>     <tr bgcolor="#9acd32">
>       <th align="left">Status</th>
>       <th align="left">Surname</th>
>          </tr>
>         <xsl:for-each select="/page/data/rows/row">
>     <tr>
>       <td><xsl:value-of select="status"/></td>
>       <td><xsl:value-of select="surname"/></td>
>     </tr>
>     </xsl:for-each>
>     </table>
>   </body>
>   </html>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> *If  I test with a browser or with XML-spy  I obtain a table, but if I 
> insert the stylesheet inside the pipeline, as a transformer  it doesn't 
> work....... only can be seen  the table header....
> 
> *<html>
>     <body>
> <h2>List of Patient</h2>
>    <table border="1">
>  <tr bgcolor="#9acd32">
> <th align="left">Status</th>
> <th align="left">Surname</th>
> </tr>
> </table>
> </body>
> </html>*
> *
> 
> 
> 
> *I'm a bit lost....
> 
> ANY suggestion??
> 
> thanks very much.
> 
> manuel ottaviano
> *

--

This email is from Civica Pty Limited and it, together with 
any attachments, is confidential to the intended recipient(s) 
and the contents may be legally privileged or contain 
proprietary and private information. It is intended solely 
for the person to whom it is addressed. If you are not an 
intended recipient, you may not review, copy or distribute 
this email. If received in error, please notify the sender 
and delete the message from your system immediately. Any 
views or opinions expressed in this email and any files 
transmitted with it are those of the author only and may 
not necessarily reflect the views of Civica and do not create 
any legally binding rights or obligations whatsoever. Unless 
otherwise pre-agreed by exchange of hard copy documents 
signed by duly authorised representatives, contracts may not 
be concluded on behalf of Civica by email. Please note that 
neither Civica nor the sender accepts any responsibility for 
any viruses and it is your responsibility to scan the email 
and the attachments (if any). All email received and sent by 
Civica may be monitored to protect the business interests of 
Civica. 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org