If you're using Xalan, there is an XSLT extension that will let you do
this.  You could embed the code to save changes in the same XSL file you
use for presentation, depending on a request parameter.

<map:generate src="docs/yourXMLfile.xml"/>
   <map:transform src="stylesheets/xalanStylesheet.xsl">
    <map:parameter name="use-request-parameters" value="true"/>
   </map:transform>
<map:serialize/>


xalanStylesheet.xsl would look something like this:

<?xml version="1.0"?>
<xsl:stylesheet  exclude-result-prefixes="*"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xalan="org.apache.xalan.xslt.extensions.Redirect"
extension-element-prefixes="xalan" version="1.0">
   <xsl:strip-space elements="*" />
   <xsl:output method="xml" indent="yes" otput:indent-amount="5"
xmlns:otput="http://xml.apache.org/xslt"; />
   <xsl:param name="save"/>
   <xsl:param name="mytext"/>
   <xsl:template match="/mydoc">
      <html>
         <xsl:choose>
            <xsl:when test="$save = '1'">
               <xsl:variable name="file"
select="concat('../docs/','yourXMLfile.xml')"/>
               <xalan:write select="$file">
                    <mydoc>
                     <mytext><xsl:value-of select="$mytext"/></mytext>
                    </mydoc>
               </xalan:write>
               <p><xsl:value-of select="$mytext"/></p>
            </xsl:when>
            <xsl:otherwise>
               <p><xsl:value-of select="mytext"/></p>
            </xsl:otherwise>
         </xsl:choose>
      </html>
   </xsl:template>
</xsl:stylesheet>


good luck


-----Original Message-----
From: Vadim Gritsenko [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, September 18, 2002 6:46 AM
To: [EMAIL PROTECTED]
Subject: Re: how to write data to the XML file which the data is read
from ?

funing wrote:

>Hi! all:
>  I am a newbie on cocoon and xsp. I want to know if it is possible 
>to  write data to the XML file which the data is read from. That means,
>I can get some data from a xml file, and transform it to a html and
>present it to a user. The user may change the data. How can I save the 
>changes to the VERY xml which the data comes from?
>
>  I think serializer may be the answer. But I don't know how to
generate
>a xml file dynamically without http response.
>

See <slash-edit/> demo. It's under mount/edit in the scratchpad/webapp.

Vadim


>best regards
>  
>




---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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

Reply via email to