You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by 32...@gmail.com on 2006/06/19 09:09:06 UTC

Interprete XML

Hello

my sitemap entry:

<map:match pattern="object">
       <map:generate type="file" src="documents/xml/sql.xml"/>
       <map:transform type="sql">
            <map:parameter name="use-connection" value="mysql-pool"/>
            <map:parameter name="nr" value="{request-param:nr}"/>
       </map:transform>
       <map:transform src="documents/stylesheets/object.xsl"/>
       <map:serialize type="xhtml"/>
</map:match>


As you can see, I generate a xml file via SQL Transformer, and transform it
to XHTML via XSL Stylesheet.
One element <sql:desc> looks like that:

<sql:desc>
Apache Cocoon, often just called Cocoon, is a web development framework
built around the concepts of separation of concerns and component-based web
development. <br> The framework focuses on XML and XSLT publishing and is
built using the Java programming language. <br> The flexibility afforded by
relying heavily on XML allows rapid content publishing in a variety of
formats including HTML, PDF, and WML.
</sql:desc>

Now, my XHTML should make a line-break everytime it finds a <br>. How can I
make this possible? Until now, it just takes the <br> as a 'normal' word.

Thank you for your help
Marco

Re: Interprete XML

Posted by 32...@gmail.com.
I appreciate your effort. It works now...


2006/6/19, Bertrand Delacretaz <bd...@apache.org>:
>
> On 6/19/06, 321los@gmail.com <32...@gmail.com> wrote:
>
> > ...But how can I access the transformed line in my xsl stylesheet?
> Normally,
> > without these kind of issues, I just do it this way:
> >
> > <xsl:template match="sql:rowset/sql:row">
> >      ...
> >     <p>Description: <xsl:value-of select="./sql:desc"/></p>
> >     ....
> > </xsl:template>
>
> xsl:value-of loses the markup and copies only the text, so you lose
> your <br/> as you've noticed.
>
> To keep them, you could do something like
>
>   <p>
>     <xsl:apply-templates select="sql:desc" mode="copy"/>
>   </p>
>
> And then have the copy mode copy all elements, like
>
> <xsl:template match="*" mode="copy">
>     <xsl:copy>
>       <xsl:copy-of select="@*"/>
>       <xsl:apply-templates mode="copy"/>
>     </xsl:copy>
>   </xsl:template>
>
> There are other ways but this should work.
>
> -Bertrand
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Re: Interprete XML

Posted by Bertrand Delacretaz <bd...@apache.org>.
On 6/19/06, 321los@gmail.com <32...@gmail.com> wrote:

> ...But how can I access the transformed line in my xsl stylesheet? Normally,
> without these kind of issues, I just do it this way:
>
> <xsl:template match="sql:rowset/sql:row">
>      ...
>     <p>Description: <xsl:value-of select="./sql:desc"/></p>
>     ....
> </xsl:template>

xsl:value-of loses the markup and copies only the text, so you lose
your <br/> as you've noticed.

To keep them, you could do something like

  <p>
    <xsl:apply-templates select="sql:desc" mode="copy"/>
  </p>

And then have the copy mode copy all elements, like

<xsl:template match="*" mode="copy">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates mode="copy"/>
    </xsl:copy>
  </xsl:template>

There are other ways but this should work.

-Bertrand

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


Re: Interprete XML

Posted by 32...@gmail.com.
Indeed you are right. When I omit the xsl stylesheet, it works as supposed.

But how can I access the transformed line in my xsl stylesheet? Normally,
without these kind of issues, I just do it this way:

<xsl:template match="sql:rowset/sql:row">
     ...
    <p>Description: <xsl:value-of select="./sql:desc"/></p>
    ....
</xsl:template>

The cocoon example in samples/blocks/html does it like this:

<xsl:template match="*/html">
      <xsl:apply-templates select="body/node()"/>
</xsl:template>

<xsl:template match="*" priority="-1">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>



How would the above be in my case. Sorry for these noobish questions...
Thanks


2006/6/19, Bertrand Delacretaz <bd...@apache.org>:
>
> On 6/19/06, 321los@gmail.com <32...@gmail.com> wrote:
>
> > ...Only in the output it changes "&lt;br/&gt;" to
> > "<br/>"; but no line break..
>
> Might be your documents/stylesheets/object.xsl eating these <br/>?
>
> I'd check the HTML source code of the final output to see what's wrong.
>
> -Bertrand
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Re: Interprete XML

Posted by Bertrand Delacretaz <bd...@apache.org>.
On 6/19/06, 321los@gmail.com <32...@gmail.com> wrote:

> ...Only in the output it changes "&lt;br/&gt;" to
> "<br/>"; but no line break..

Might be your documents/stylesheets/object.xsl eating these <br/>?

I'd check the HTML source code of the final output to see what's wrong.

-Bertrand

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


Re: Interprete XML

Posted by 32...@gmail.com.
Thanks for your answer, Bertrand

now, my sitemap looks like that (HTML Transformer is registered)

<map:match pattern="object">
       <map:generate type="file" src="documents/xml/sql.xml"/>
       <map:transform type="sql">
            <map:parameter name="use-connection" value="mysql-pool"/>
            <map:parameter name="nr" value="{request-param:nr}"/>
       </map:transform>
       <map:transform type="html">
          <map:parameter name="tags" value="desc"/>
        </map:transform>
       <map:transform src="documents/stylesheets/object.xsl"/>
       <map:serialize type="xhtml"/>
</map:match>

I managed to change <br> to &lt;br/&gt; in <sql:desc> (otherwise it shows an
error):

<sql:desc>
Apache Cocoon, often just called Cocoon, is a web development framework
built around the concepts of separation of concerns and component-based web
development. &lt;br/&gt; The framework focuses on XML and XSLT publishing
and is built using the Java programming language. &lt;br/&gt; The
flexibility afforded by relying heavily on XML allows rapid content
publishing in a variety of formats including HTML, PDF, and WML.
</sql:desc>

But it still doesn't work. Only in the output it changes "&lt;br/&gt;" to
"<br/>"; but no line break.
Am I missing something else...?

Thank you again



2006/6/19, Bertrand Delacretaz <bd...@apache.org>:
>
> On 6/19/06, 321los@gmail.com <32...@gmail.com> wrote:
>
> > ...Now, my XHTML should make a line-break everytime it finds a <br>. How
> can I
> > make this possible? Until now, it just takes the <br> as a 'normal'
> word....
>
> Most probably because your <br> are part of the element's text, they
> are not really XML elements.
>
> The HtmlTransformer allows you to parse such elements, that's probably
> what you want. See
> http://cocoon.zones.apache.org/demos/release/samples/blocks/html/welcome
>
> -Bertrand
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Re: Interprete XML

Posted by Bertrand Delacretaz <bd...@apache.org>.
On 6/19/06, 321los@gmail.com <32...@gmail.com> wrote:

> ...Now, my XHTML should make a line-break everytime it finds a <br>. How can I
> make this possible? Until now, it just takes the <br> as a 'normal' word....

Most probably because your <br> are part of the element's text, they
are not really XML elements.

The HtmlTransformer allows you to parse such elements, that's probably
what you want. See
http://cocoon.zones.apache.org/demos/release/samples/blocks/html/welcome

-Bertrand

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