You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Matteo <tu...@email.it> on 2004/01/03 14:11:25 UTC

Trouble transforming EMPTY tag [Cocoon 2.1.4]

Problem description:
When a try to transform an empty tag from an XML content to an HTML 
formatting the resulting tag in the HTML page has not the closing part.



Code Example (this example is semplified but I tested it doesn't work 
the same way the original problem):

here is the XML file with the content (test.xml):
<page>
    <logo/>
</page>

here is the XSL stylesheet (test2html.xsl)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="page">
        <html>
        <head>
            <title>test</title>
        </head>
        <body>
            <xsl:apply-templates select="logo"/>
        </body>
        </html>
    </xsl:template>
    <xsl:template match="logo">
        <img src="data/image/oilogo.jpg" alt="logo"></img>
    </xsl:template>
</xsl:stylesheet>

here is the sitemap entry for the page (extract from sitemap.xmap):
        <map:pipeline>
            <map:match pattern="test.htm">
                <map:generate src="laos/xml/test.xml"/>
                <map:transform src="laos/xsl/test2html.xsl"/>
                <map:serialize type="html"/>
            </map:match>
        </map:pipeline>

here is the resulting html code from transformation (test.htm):

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>test</title>
</head>
<body>
<img alt="logo" src="data/image/oilogo.jpg"></body>
</html>

Any clue why the <img> doesn't end with <img/>?
Thanks in advance for the help!

    Matteo


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


Re: Trouble transforming EMPTY tag [Cocoon 2.1.4]

Posted by Matteo <tu...@email.it>.
Thanks you very much... i'm very new to cocoon (only a week) ;)

    Matteo

J.Pietschmann wrote:

>
> That's because you are serializing as HTML. HTML is not
> XML. THere is no closing tag for IMG necesary.
> If you want XHTML, try
>  <map:serialize type="xml"/>



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


Re: Trouble transforming EMPTY tag [Cocoon 2.1.4]

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Matteo wrote:
>                <map:serialize type="html"/>
...
> <img alt="logo" src="data/image/oilogo.jpg"></body>
> </html>
> 
> Any clue why the <img> doesn't end with <img/>?
> Thanks in advance for the help!

That's because you are serializing as HTML. HTML is not
XML. THere is no closing tag for IMG necesary.
If you want XHTML, try
  <map:serialize type="xml"/>

Older browsers will choke on the generated XHTML though.

There is no easy standard method to serialize XHTML, in a
way which generates both valid XML and code acceptable to
older browsers (<br /> instead of <br/>).

J.Pietschmann


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