I had this problem too, and had to write a custom java class to do this
inside XSLT, but it works.  

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0" xmlns:java="http://xml.apache.org/xslt/java";
exclude-result-prefixes="java">
<xsl:template match="/">
<xsl:variable name="convertThisNode">
<xsl:copy-of select="/page/thing"/>
</xsl:variable>
<html>
<form>
<input name="txtNode"><xsl:attribute name="value">
<xsl:value-of
select="java:agler.SerializeXml.serializeXml($convertThisNode)"/></xsl:a
ttribute>
</input>
</form>
</html>
</xsl:template>
</xsl:stylesheet>

Not sure if you are familiar with making your own Jars (took me awhile
to figure out), but if you are, create you own jar and make it available
to Cocoon by putting it in Tomcat's common/lib and reference it in
web.xml's extra-classpath.  Here is the source for SerializeXml:

package agler;
import org.w3c.dom.Node;
import org.apache.xalan.serialize.SerializerToXML;
import java.io.StringWriter;
public class SerializeXml
{
   public static String serializeXml(Node node)
   {
      String ret = "";
      try 
      {
        StringWriter sw = new StringWriter();
        SerializerToXML serxml = new SerializerToXML();
        serxml.setWriter(sw);
        serxml.serialize(node);
          ret = sw.toString();
      }
      catch (Exception e){}
      return ret;
   }
}

Hope this helps, good luck.
+Ryan




-----Original Message-----
From: ROSSEL Olivier [mailto:olivier.rossel@;airbus.com] 
Sent: Wednesday, October 23, 2002 5:05 AM
To: '[EMAIL PROTECTED]'
Subject: [Off-topic:XSLT] Passing an XML fragment via a HTML form.

I have a HTML form, created from a XML file and a XSL Treansformation.

I need to pass a subtree of that XML as a parameter, via that form.

Is there a way, in XSLT, to transform a XML fragment into a string?
So I can have an <input> in my form that contains the text of this XML
fragment.

Corrolair when processing parameters sent by the form: 
is there a way, in XSLT, to transform as string into a XML fragment?




---cut here---


This e-mail is intended only for the above addressee. It may contain
privileged information. If you are not the addressee you must not copy,
distribute, disclose or use any of the information in it. If you have
received it in error please delete it and immediately notify the sender.
Security Notice: all e-mail, sent to or from this address, may be
accessed by someone other than the recipient, for system management and
security reasons. This access is controlled under Regulation of
Investigatory Powers Act 2000, Lawful Business Practises.

---------------------------------------------------------------------
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