Hi everybody,

I'm working since many years with Cocoon 2.1 within a Tomcat server and I need now to inject the content of my XML files in a MySQL database.

The problem is I have some XML elements (MySQL columns) that do contain HTML tags (some "<br/>", "<i>...</i>" and a few "<a href url="..."/>).

For now, all tags seem simply to be trimmed away from my output.

Is there a way to inject tags in a text field from Cocoon 2.1 into MySQL using <sql:execute-query>?

My database connection is defined as following in WEB-INF/cocoon.xconf:

    <jdbc name="dautrepart">
      <pool-controller min="1" max="10"/>

In the sitemap, I have these lines:

            <map:match pattern="copier.html">
<map:generate type="xpathdirectory" src="../bac_a_sable/textes" label="content">
                    <map:parameter name="xpath" value="/fiche"/>
                    <map:parameter name="include" value=".xml"/>
<map:transform src="nettoyer_structure.xslt" label="debug01"/>
                <map:transform src="preparer_sql.xslt" label="debug02"/>
                <map:transform src="injection.xslt" label="requetes"/>
                <map:transform type="sql">
<map:parameter name="use-connection" value="dautrepart"/>
                <map:serialize type="xml"/>

And concerned parts of my stylesheet appears as follow:

                    <sql:query name="inserer_auteur">
<xsl:text>INSERT INTO auteur (nom, prenom, identifiant, biographie, portrait_petit) VALUES ("</xsl:text>
                        <xsl:value-of select="identite/nom"/>
                        <xsl:text>", "</xsl:text>
                        <xsl:value-of select="identite/prenom"/>
                        <xsl:text>", "</xsl:text>
                        <xsl:value-of select="identite/@id"/>
                        <xsl:text>", "</xsl:text>
                        <xsl:apply-templates select="bio"/>
                        <xsl:text>", "</xsl:text>
                        <xsl:value-of select="identite/portrait"/>

    <xsl:template match="bio">

    <xsl:template match="i">

An extract of the file I have:

Née en 1965, elle habite dans le canton de Genève. Participe à Bern ist überall et au cd
<i>Renens (VD)</i>
. Prix suisse de littérature 2017 pour
<i>Inventaire des lieux</i>
paru chez art&fiction.

Reply via email to