You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Brent L Johnson <br...@bjohnson.net> on 2003/12/05 17:07:51 UTC
Content Updating
Im creating a basic content management system to allow users
to change the content in some of the XML documents.
I'm reading the content and putting it into a textarea and
doing a form post. To print a preview of the page I have
an XSP file that uses xsp-request to use the data that was
posted instead of the static content in the XML document.
But after being posted the data is being encoded so it comes
out as:
<img>
How can I use the posted data as XML without being encoded?
Thanks,
- Brent
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: Content Updating
Posted by Brent L Johnson <br...@bjohnson.net>.
> Look through the archives - unless I misunderstand you this
> has been discussed ad nauseum. In your case, there is an
> xsp tag to cause the value of your parameter to be parsed
> as xml and passed down the line of SAX events.
I did a quick pass over the mailing list archives but didnt
see anything. I'll search a little harder - I did figure
that had to have been something people had problems with in
the past.
But something like an xsp attribute or tag sounds exactly
like what I'm trying to find.
> Keep in mind, a cocoon pipeline is not a text stream of xml,
> but a sax event chain. inserting new text into a character
> event at one point does not create a new startElement, etc.
> unless explicitly instructed to do so. This saves us from
> continually reparsinng the xml as it moves through.
Makes sense.
Thanks,
- Brent
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: Content Updating
Posted by Brent L Johnson <br...@bjohnson.net>.
> You said you were using XSP, so that snippet is an XSP
> snippet. Won't
> work this way in XSL.
Ack sorry - I was using XSP but recently switch to XML since
I wanted to pull the logic out of the basic content documents.
Basically, I'm using an XML file as a generator. Then Im
doing a transform and using template matching to match up
the tags that I want to change with information from the
request.
- Brent
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Content Updating
Posted by Geoff Howard <co...@leverageweb.com>.
Brent L Johnson wrote:
>>I understood him to mean that he was sending a string with
>>xml data to
>>be parsed - in which case the only option is server side, and it's as
>>easy as:
>>
>><util:include-expr><util:expr><xsp-request:get-parameter name="test"
>>/></util:expr></util:include-expr>
>>
>>in an xsp page where the namespace for util is defined as:
>>xmlns:util="http://apache.org/xsp/util/2.0"
>>
>>That snippet in an xsp page called with ?test=<foo>bar</foo>
>>
>>will produce xml sax events for an element "foo" in the default
>>namespace with a nested character event of "bar".
>
>
> That's exactly what I'm trying to do. Does it have to be XSL though?
> I'm running a plain XML content document through the pipeline and
> using XSL to transform it. I use the "use-request-parameters" parameter
> for the transform call. Then in there I tried the following:
>
> <util:include-expr><util:expr><xsl:value-of
> select="$history"/></util:expr></util:include-expr>
>
> No luck though. I'll try and find some docs or another thread on this
> topic.
You said you were using XSP, so that snippet is an XSP snippet. Won't
work this way in XSL.
Geoff
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: Content Updating
Posted by Brent L Johnson <br...@bjohnson.net>.
> I understood him to mean that he was sending a string with
> xml data to
> be parsed - in which case the only option is server side, and it's as
> easy as:
>
> <util:include-expr><util:expr><xsp-request:get-parameter name="test"
> /></util:expr></util:include-expr>
>
> in an xsp page where the namespace for util is defined as:
> xmlns:util="http://apache.org/xsp/util/2.0"
>
> That snippet in an xsp page called with ?test=<foo>bar</foo>
>
> will produce xml sax events for an element "foo" in the default
> namespace with a nested character event of "bar".
That's exactly what I'm trying to do. Does it have to be XSL though?
I'm running a plain XML content document through the pipeline and
using XSL to transform it. I use the "use-request-parameters" parameter
for the transform call. Then in there I tried the following:
<util:include-expr><util:expr><xsl:value-of
select="$history"/></util:expr></util:include-expr>
No luck though. I'll try and find some docs or another thread on this
topic.
Thanks,
- Brent
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Content Updating
Posted by Geoff Howard <co...@leverageweb.com>.
Chris Morgan wrote:
> All to say that the server-side option is a pretty complicated way to do
> something that should be simple. Having gone through this, I recommend some
> form of client solution. Flash is the most ubiquitous and less obtrusive
> client options, but there are others (I think there are DHTML options)
> that'd work too.
I understood him to mean that he was sending a string with xml data to
be parsed - in which case the only option is server side, and it's as
easy as:
<util:include-expr><util:expr><xsp-request:get-parameter name="test"
/></util:expr></util:include-expr>
in an xsp page where the namespace for util is defined as:
xmlns:util="http://apache.org/xsp/util/2.0"
That snippet in an xsp page called with ?test=<foo>bar</foo>
will produce xml sax events for an element "foo" in the default
namespace with a nested character event of "bar".
Now, the fact that this does come up so frequently means there probably
should be better documentation and/or a sample - any volunteers?
Geoff
> -----Original Message-----
> From: Geoff Howard [mailto:cocoon@leverageweb.com]
> Sent: Friday, December 05, 2003 3:48 PM
> To: users@cocoon.apache.org
> Subject: Re: Content Updating
>
>
> Look through the archives - unless I misunderstand you this
> has been discussed ad nauseum. In your case, there is an
> xsp tag to cause the value of your parameter to be parsed
> as xml and passed down the line of SAX events.
>
> Keep in mind, a cocoon pipeline is not a text stream of xml,
> but a sax event chain. inserting new text into a character
> event at one point does not create a new startElement,
> etc. unless explicitly instructed to do so. This saves us
> from continually reparsinng the xml as it moves through.
>
> Geoff
>
> Brent L Johnson wrote:
>
>>Yeah this is quite annoying because as soon as I do an
>><xsl:value-of value="$myrequestparam"/>
>>
>>That produces an encoded string value that gets passed
>>all the way to the actual writing of the file.. so it
>>gets overwritten with < and >
>>
>>- Brent
>>
>>
>>
>>>I've run into this as well. We looked at a couple of
>>>different options:
>>>
>>>1. server side decoders that basically replace your < or
>>>other unicode with their appropriate symbols before
>>>committing to storage. This is a good solution for very
>>>simple markup with little variation.
>>>
>>>2. Change client to applets, ActiveX or Flash. We chose to
>>>build a flash component based on the following
>>>http://www.flashcomponents.net/component.cfm?nav=2&id=131.
>>>Macromedia has a
>>>pretty decent API for sending and receiving XML.
>>>Performance isn't
>>>great though. We use it as a dumb-client and do all XML
>>>processing on the server.
>>>
>>>Hope this helps,
>>>
>>>Chris
>>>
>>>-----Original Message-----
>>>From: Brent L Johnson [mailto:brent@bjohnson.net]
>>>Sent: Friday, December 05, 2003 11:08 AM
>>>To: users@cocoon.apache.org
>>>Subject: Content Updating
>>>
>>>
>>>Im creating a basic content management system to allow users
>>>to change the content in some of the XML documents.
>>>
>>>I'm reading the content and putting it into a textarea and
>>>doing a form post. To print a preview of the page I have an
>>>XSP file that uses xsp-request to use the data that was
>>>posted instead of the static content in the XML document.
>>>
>>>But after being posted the data is being encoded so it comes out as:
>>>
>>><img>
>>>
>>>How can I use the posted data as XML without being encoded?
>>>
>>>Thanks,
>>>
>>>- Brent
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: Content Updating
Posted by Chris Morgan <ch...@atomicdog.com>.
All to say that the server-side option is a pretty complicated way to do
something that should be simple. Having gone through this, I recommend some
form of client solution. Flash is the most ubiquitous and less obtrusive
client options, but there are others (I think there are DHTML options)
that'd work too.
Chris
-----Original Message-----
From: Geoff Howard [mailto:cocoon@leverageweb.com]
Sent: Friday, December 05, 2003 3:48 PM
To: users@cocoon.apache.org
Subject: Re: Content Updating
Look through the archives - unless I misunderstand you this
has been discussed ad nauseum. In your case, there is an
xsp tag to cause the value of your parameter to be parsed
as xml and passed down the line of SAX events.
Keep in mind, a cocoon pipeline is not a text stream of xml,
but a sax event chain. inserting new text into a character
event at one point does not create a new startElement,
etc. unless explicitly instructed to do so. This saves us
from continually reparsinng the xml as it moves through.
Geoff
Brent L Johnson wrote:
> Yeah this is quite annoying because as soon as I do an
> <xsl:value-of value="$myrequestparam"/>
>
> That produces an encoded string value that gets passed
> all the way to the actual writing of the file.. so it
> gets overwritten with < and >
>
> - Brent
>
>
>>I've run into this as well. We looked at a couple of
>>different options:
>>
>>1. server side decoders that basically replace your < or
>>other unicode with their appropriate symbols before
>>committing to storage. This is a good solution for very
>>simple markup with little variation.
>>
>>2. Change client to applets, ActiveX or Flash. We chose to
>>build a flash component based on the following
>>http://www.flashcomponents.net/component.cfm?nav=2&id=131.
>>Macromedia has a
>>pretty decent API for sending and receiving XML.
>>Performance isn't
>>great though. We use it as a dumb-client and do all XML
>>processing on the server.
>>
>>Hope this helps,
>>
>>Chris
>>
>>-----Original Message-----
>>From: Brent L Johnson [mailto:brent@bjohnson.net]
>>Sent: Friday, December 05, 2003 11:08 AM
>>To: users@cocoon.apache.org
>>Subject: Content Updating
>>
>>
>>Im creating a basic content management system to allow users
>>to change the content in some of the XML documents.
>>
>>I'm reading the content and putting it into a textarea and
>>doing a form post. To print a preview of the page I have an
>>XSP file that uses xsp-request to use the data that was
>>posted instead of the static content in the XML document.
>>
>>But after being posted the data is being encoded so it comes out as:
>>
>><img>
>>
>>How can I use the posted data as XML without being encoded?
>>
>>Thanks,
>>
>>- Brent
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Content Updating
Posted by Geoff Howard <co...@leverageweb.com>.
Look through the archives - unless I misunderstand you this
has been discussed ad nauseum. In your case, there is an
xsp tag to cause the value of your parameter to be parsed
as xml and passed down the line of SAX events.
Keep in mind, a cocoon pipeline is not a text stream of xml,
but a sax event chain. inserting new text into a character
event at one point does not create a new startElement,
etc. unless explicitly instructed to do so. This saves us
from continually reparsinng the xml as it moves through.
Geoff
Brent L Johnson wrote:
> Yeah this is quite annoying because as soon as I do an
> <xsl:value-of value="$myrequestparam"/>
>
> That produces an encoded string value that gets passed
> all the way to the actual writing of the file.. so it
> gets overwritten with < and >
>
> - Brent
>
>
>>I've run into this as well. We looked at a couple of
>>different options:
>>
>>1. server side decoders that basically replace your < or
>>other unicode with their appropriate symbols before
>>committing to storage. This is a good solution for very
>>simple markup with little variation.
>>
>>2. Change client to applets, ActiveX or Flash. We chose to
>>build a flash component based on the following
>>http://www.flashcomponents.net/component.cfm?nav=2&id=131.
>>Macromedia has a
>>pretty decent API for sending and receiving XML.
>>Performance isn't
>>great though. We use it as a dumb-client and do all XML
>>processing on the server.
>>
>>Hope this helps,
>>
>>Chris
>>
>>-----Original Message-----
>>From: Brent L Johnson [mailto:brent@bjohnson.net]
>>Sent: Friday, December 05, 2003 11:08 AM
>>To: users@cocoon.apache.org
>>Subject: Content Updating
>>
>>
>>Im creating a basic content management system to allow users
>>to change the content in some of the XML documents.
>>
>>I'm reading the content and putting it into a textarea and
>>doing a form post. To print a preview of the page I have an
>>XSP file that uses xsp-request to use the data that was
>>posted instead of the static content in the XML document.
>>
>>But after being posted the data is being encoded so it comes out as:
>>
>><img>
>>
>>How can I use the posted data as XML without being encoded?
>>
>>Thanks,
>>
>>- Brent
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: Content Updating
Posted by Edison Too <ed...@yahoo.com.sg>.
Hi,
Our solution is as below, maybe it will give you some idea. But we don't use XSP.
In the form a simple javascript is used to pass the context as cdata section. wrapped inside an element named "staticDesign".
<xsl:template match="staticDesign">
<form name="dummyForm">
<textarea rows="25" wrap="off" name="inputArea" style="font-family: courier new; width: 90%;">
<xsl:value-of disable-output-escaping="yes" select="text()"/>
</textarea>
</form>
<form action="yourAction" name="staticDesign" method="post"
onsubmit="this.designContent.value='<staticDesign><![CDATA['+document.dummyForm.inputArea.value+']]></staticDesign>';">
<input type="hidden" name="designContent"/>
<input type="submit" name="submit" value="Save"/>
</form>
</xsl:template>
In the sitemap, we use the Stream generator to take the single input (designContent) as the generated xml, them we use SourceWriting Transformer to write the xml into a file
<map:match pattern="sav*/**">
<map:generate type="stream">
<map:parameter name="form-name" value="designContent"/>
</map:generate>
<!-- Wrap the "staticDesign" inside SourceWriting elements for the next step
<map:transform src="write.xsl">
<map:parameter name="filename" value="{request-param:cms-file_name}"/>
</map:transform>
<map:transform type="write-source">
<!-- have to use a special xml serializer so that staticDesign elements are treated
as cdata section-->
<map:parameter name="serializer" value="scxml"/>
</map:transform>
<map:serialize type="html"/>
</map:match>
The fact is, we wrap the content as a CDATA section inside a single "staticDesign" element. In this way the <> are preserved. When putting it into the form, the disable-output-escaping="yes" attribute prevent it from becoming ><.
One last point to make this work is that a special xml serializer must be used for the SourceWriting Transformer.
<map:serializer logger="sitemap.serializer.scxml" mime-type="text/xml" name="scxml" src="org.apache.cocoon.serialization.XMLSerializer">
<cdata-section-elements>staticDesign</cdata-section-elements>
</map:serializer>
Sorry for such a long post, I understand that our usage may not be the way you want to work with it. But just thought it might give you some ideas to work on.
Cheers,
Edison
On Fri, 5 Dec 2003 15:41:35 -0500, Brent L Johnson wrote:
>Yeah this is quite annoying because as soon as I do an <xsl:value-of
>value="$myrequestparam"/>
>
>That produces an encoded string value that gets passed all the way to the
>actual writing of the file.. so it gets overwritten with < and >
>
>- Brent
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: Content Updating
Posted by Brent L Johnson <br...@bjohnson.net>.
Yeah this is quite annoying because as soon as I do an
<xsl:value-of value="$myrequestparam"/>
That produces an encoded string value that gets passed
all the way to the actual writing of the file.. so it
gets overwritten with < and >
- Brent
> I've run into this as well. We looked at a couple of
> different options:
>
> 1. server side decoders that basically replace your < or
> other unicode with their appropriate symbols before
> committing to storage. This is a good solution for very
> simple markup with little variation.
>
> 2. Change client to applets, ActiveX or Flash. We chose to
> build a flash component based on the following
> http://www.flashcomponents.net/component.cfm?nav=2&id=131.
> Macromedia has a
> pretty decent API for sending and receiving XML.
> Performance isn't
> great though. We use it as a dumb-client and do all XML
> processing on the server.
>
> Hope this helps,
>
> Chris
>
> -----Original Message-----
> From: Brent L Johnson [mailto:brent@bjohnson.net]
> Sent: Friday, December 05, 2003 11:08 AM
> To: users@cocoon.apache.org
> Subject: Content Updating
>
>
> Im creating a basic content management system to allow users
> to change the content in some of the XML documents.
>
> I'm reading the content and putting it into a textarea and
> doing a form post. To print a preview of the page I have an
> XSP file that uses xsp-request to use the data that was
> posted instead of the static content in the XML document.
>
> But after being posted the data is being encoded so it comes out as:
>
> <img>
>
> How can I use the posted data as XML without being encoded?
>
> Thanks,
>
> - Brent
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: Content Updating
Posted by Chris Morgan <ch...@atomicdog.com>.
I've run into this as well. We looked at a couple of different options:
1. server side decoders that basically replace your < or other unicode
with their appropriate symbols before committing to storage. This is a good
solution for very simple markup with little variation.
2. Change client to applets, ActiveX or Flash. We chose to build a flash
component based on the following
http://www.flashcomponents.net/component.cfm?nav=2&id=131. Macromedia has a
pretty decent API for sending and receiving XML. Performance isn't
great though. We use it as a dumb-client and do all XML processing on the
server.
Hope this helps,
Chris
-----Original Message-----
From: Brent L Johnson [mailto:brent@bjohnson.net]
Sent: Friday, December 05, 2003 11:08 AM
To: users@cocoon.apache.org
Subject: Content Updating
Im creating a basic content management system to allow users
to change the content in some of the XML documents.
I'm reading the content and putting it into a textarea and
doing a form post. To print a preview of the page I have
an XSP file that uses xsp-request to use the data that was
posted instead of the static content in the XML document.
But after being posted the data is being encoded so it comes
out as:
<img>
How can I use the posted data as XML without being encoded?
Thanks,
- Brent
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org