Hi

I'm using Cocoon 2.0.4 with Tomcat 4.0.4, Apache 1.3.26 and Java 1.3.1.

After having modified the sunspotdemoportal to perform authentication with a
database instead of with files, I'm trying now to solve the next problem
i.e. how to store user profile and status on the database instead to create
a lot of files on the system.

I added to my user table in mysql 1.3.23.52 the two fields profile and
status of type TEXT (till max 65536 characters each).

After this I added following resource in the sitemap:

        <map:match pattern="vipresource-saveuserprofile">
          <map:generate src="vip/resources/saveuserprofile-db.xml"/>
          <map:transform type="sunShine"/>
          <map:transform src="vip/styles/saveuserprofile-db.xsl"/>
          <map:transform type="sql"/>
          <map:transform src="vip/styles/saveuserprofile-sql.xsl"/>
          <map:serialize type="xml"/>
        </map:match>

This is the file saveuserprofile-db.xml:

<?xml version="1.0"?> <!-- saveuserprofile-db.xml -->

<userdelta xmlns:sunshine="http://cocoon.apache.org/sunshine/1.0";>
  <name><sunshine:getxml context="request" path="/parameter/ID"/></name>
  <fragment><sunshine:getxml context="request"
path="/parameter/content"/></fragment>
</userdelta>

After the generator and the sunShine transformer I get the <name> and
<fragment> elements filled with the current values and I'm trying to put
them in a SQL statement with following stylesheet:

<?xml version="1.0"?> <!-- saveuserprofile-db.xsl -->
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="userdelta">
  <userdelta>
    <sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0";>
      <sql:use-connection>vip_db</sql:use-connection>
      <sql:query>
        update user_tb
           set profile = '<xsl:copy-of select="fragment"/>'
           where name = '<xsl:value-of select="name"/>'
      </sql:query>
    </sql:execute-query>
  </userdelta>
</xsl:template>

</xsl:stylesheet>

The file saveuserprofile-sql.xsl for postprocessing the results of the SQL
query is not relevant and I have omitted it in this mail.

Looking in the logfile I can see that there is an item with the sql update
statement with substituted values for profile and name, where profile
contains the xml tree in the desired form. The following item in the logfile
shows the same statement where the profile content is no more the xml tree
but only the text part of it with a lot of blank lines and without any
element tags.

If I look at the stored values in the database I see exactly this last
content without element tags.

Here a simplified test showing a similar extract from the logfile:

2003-06-04 16:51:44 DEBUG   (2003-06-04) 16:51.44:156   [sitemap.]
(/cocoon-min/test-saveuserprofile-db)
HttpProcessor[8080][10]/AbstractSAXTransformer: END endRecording
fragment=<?xml version="1.0" encoding="ISO-8859-1"?>
        update user_tb
           set profile = '<fragment
xmlns:sunshine="http://cocoon.apache.org/sunshine/1.0";>
<mytest>
<myelement>The value</myelement>
</mytest>
</fragment>'
           where name = 'test'

2003-06-04 16:51:44 DEBUG   (2003-06-04) 16:51.44:165   [sitemap.]
(/cocoon-min/test-saveuserprofile-db)
HttpProcessor[8080][10]/AbstractSAXTransformer: END
endSerializedXMLRecording xml=
        update user_tb
           set profile = 'The value'
           where name = 'test'

The other way would be to analyze which are the contents of status and
profile and map them to database tables, what I think can be very complex
and preferably to avoid.

HERE ARE MY QUESTIONS:

1) How can I store an user profile and status on the database?
2) Is there an easier way to solve it and to avoid a large number of created
files?
3) Beside this, there is the problem to escape characters like apostrophs or
german umlauts. How can be done this?

Thanks for your opinions and suggestions
Enrico



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to