You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Lochschmied, Alexander" <Al...@vishay.com> on 2017/01/30 08:16:57 UTC
2.1.13 sqltransformer entities
We upgraded recently from 2.1.11 to some 2.1.13 version from SVN (as we upgraded machines to Java 8).
Now entities in our MySQL DB seem to be treated differently. So for example we see ® in our resulting HTML pages now instead of the corresponding "registered trademark" symbol. A workaround seems to be having the DB content start with an (empty) XML comment for example.
Is there a way to get back the old behaviour so we won't have to apply this workaround to all our data?
Thanks,
Alexander
Is there a way to inject tags in a text field from Cocoon 2.1 into
MySQL using sql:execute-query?
Posted by Philippe Faehndrich <ph...@bluewin.ch>.
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"/>
<dburl>jdbc:mysql://localhost:3306/dautrepart</dburl>
<user>webapp</user>
<password>webapp</password>
</jdbc>
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:generate>
<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:transform>
<map:serialize type="xml"/>
</map:match>
And concerned parts of my stylesheet appears as follow:
<sql:execute-query>
<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:text>")</xsl:text>
</sql:query>
</sql:execute-query>
<xsl:template match="bio">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="i">
<i>
<xsl:apply-templates/>
</i>
</xsl:template>
An extract of the file I have:
<fiche>
<identiteid="boissier_laurence">
<nom>Boissier</nom>
<prenom>Laurence</prenom>
<portrait>boissier_laurence_150x100.png</portrait>
</identite>
<bio>
Ne en 1965, elle habite dans le canton de Genve. Participe Bern ist
berall et au cd
<i>Renens (VD)</i>
. Prix suisse de littrature 2017 pour
<i>Inventaire des lieux</i>
paru chez art&fiction.
<br/>
</bio>