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/12 12:57:06 UTC

XSLT Transformer Problem: STILL I'm Lost :(

*Hello Cocoon World I contact you again because I'm desperate....

I've a match process inside a pipeline that receives XML data from a Web 
Service , it merges with other translated data.

After this process the results is :*

<?xml version="1.0" encoding="ISO-8859-1"?>
<page xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
<meta-data>Castelano</meta-data>
   &lt;data&gt;
	&lt;product&gt;Hearth Failure Management&lt;/product&gt;
	&lt;error_code&gt;200&lt;/error_code&gt;

	&lt;command&gt;List of Patient&lt;/command&gt;
	&lt;rows&gt;
		&lt;row&gt;
			&lt;status&gt;Alert!&lt;/status&gt;
			&lt;surname&gt;Rodriguez&lt;/surname&gt;

			&lt;name&gt;Manuel&lt;/name&gt;
			&lt;chn&gt;1234556789&lt;/chn&gt;
			&lt;age&gt;60&lt;/age&gt;
			&lt;gender&gt;F&lt;/gender&gt;

			&lt;lastSeen&gt;lastSeen&lt;/lastSeen&gt;
			&lt;patientID&gt;1563&lt;/patientID&gt;
		&lt;/row&gt;

	&lt;/rows&gt;
&lt;/data&gt;

</page>

*I want to transform this result in a XHTML table.
I add the 3 following stylesheet:
*

    * *tagger.xsl that transform < > html codes in  ><*
    * *nonamespace.xsl  that removes namespaces*

*This is the partial result :*

<?xml version="1.0" encoding="ISO-8859-1"?>
<page>
<meta-data>Castelano</meta-data>
   <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>

	</rows>
</data>

</page>

    * *table.xsl is the styleshhet to format the table. I use this code: *

<xsl:stylesheet version="1.0"   
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  <xsl:template match="page">
  <html>  <body>       <xsl:apply-templates/>  </body></html>
  </xsl:template>
 <xsl:template match="rows">
    <table border="1">    <tbody>   <tr>  <th></th>  </tr>   </tbody>
     <xsl:apply-templates/>
             </table>
      </xsl:template>
   <xsl:template match="row">
    <tr><xsl:apply-templates/></tr>
      </xsl:template>
 <xsl:template match="status">
    <td>     <xsl:apply-templates/>       </td>
      </xsl:template>
 <xsl:template match="status">
    <td>      <xsl:apply-templates/>       </td>
      </xsl:template>
       <xsl:template match="surname">
    <td>      <xsl:apply-templates/>       </td>
      </xsl:template>
       <xsl:template match="name">
    <td>      <xsl:apply-templates/>       </td>
      </xsl:template>
           <xsl:template match="chn">
    <td>      <xsl:apply-templates/>       </td>
      </xsl:template>
           <xsl:template match="age">
    <td>      <xsl:apply-templates/>       </td>
      </xsl:template>
           <xsl:template match="gender">
    <td>      <xsl:apply-templates/>       </td>
      </xsl:template>
           <xsl:template match="lastSeen">
    <td>      <xsl:apply-templates/>       </td>
      </xsl:template>
           <xsl:template match="patientID">
    <td>      <xsl:apply-templates/>       </td>
      </xsl:template>
</xsl:stylesheet>

*But this is the result:
*  <?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><body>
Castelano
   &lt;data&gt;
	&lt;product&gt;Hearth Failure Management&lt;/product&gt;
	&lt;error_code&gt;200&lt;/error_code&gt;
	&lt;command&gt;List of Patient&lt;/command&gt;

	&lt;rows&gt;
		&lt;row&gt;
			&lt;status&gt;Alert!&lt;/status&gt;
			&lt;surname&gt;Rodriguez&lt;/surname&gt;
			&lt;name&gt;Manuel&lt;/name&gt;

			&lt;chn&gt;1234556789&lt;/chn&gt;
			&lt;age&gt;60&lt;/age&gt;
			&lt;gender&gt;F&lt;/gender&gt;
			&lt;lastSeen&gt;lastSeen&lt;/lastSeen&gt;

			&lt;patientID&gt;1563&lt;/patientID&gt;
		&lt;/row&gt;
		


	&lt;/rows&gt;
&lt;/data&gt;

</body></html>


 
*The table.xsl transformer does not works and also it converts tag in 
html code .... :(
But if I save the partial result [see the  XML shown before table.xsl 
code] in a file and I apply the table.xsl styleshett it works correctly. 
I also test this feature inside a match process of Cocoon's pipeline and 
it works fine... [*http://idle.lst.tfo.upm.es:8080/cocoon/hfm/prova *]*
*This is the the code of the pipeline:

* <map:match pattern="result">
      <map:generate type="jx"  src="flow2ws.xml"/>
                <map:transform type="i18n">
                <map:parameter name="default-catalogue-id" 
value="messages"  location="translations"/>
            <map:parameter name="locale" value="{../locale}"/>
          </map:transform>
        <map:transform src="nonamespace.xsl"/>   
            <map:transform src="tagger.xsl"/>  
                <map:transform src="table.xsl"/> 
            <map:serialize type="xhtml"/>
   </map:match> 

and if you want to see the results:

*http://idle.lst.tfo.upm.es:8080/cocoon/hfm/product?data=data&pipe=result*

*And this is very strange:*

http://idle.lst.tfo.upm.es:8080/cocoon/hfm/prova  * is a process that 
use the partial XML as static file and apply the table.xsl 
transformer..... this work!!!

Why it does not work in my process.....????
*
*_
THANKS VERY MUCH_

manuel ottaviano
*
*









Re: XSLT Transformer Problem: STILL I'm Lost :(

Posted by Askild Aaberg Olsen <as...@xangeli.com>.
Manuel Ottaviano wrote:
> ***And this is very strange:*
>
> http://idle.lst.tfo.upm.es:8080/cocoon/hfm/prova  * is a process that 
> use the partial XML as static file and apply the table.xsl 
> transformer..... this work!!!
>
> Why it does not work in my process.....????
> *
Hi Manuel!

I don't think that your tagger.xsl is the way to go, the resulting 
SAX-stream from it is still just a string, but when you save it to file, 
the generator parses i correctly. This is why your partial XML is working.

The answer is to parse this string somehow...

Are you able to use Saxon instead of Xalan as XSLT-processor?
Saxon has a parse() - function,  that could save your day.

Have a look at
http://wiki.apache.org/cocoon/Saxon
and
http://www.saxonica.com/documentation/extensions/functions/parse.html

I've had problems using Saxon 8.8 in Cocoon, but success with 8.7.3, and 
have used the parse()-function several times.

Hope this helps.

Askild
-

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