XSL uses XPath functions. See: http://www.w3.org/TR/xpath#section-String-Functions translate() will not do what you want because it replaces single characters. You can (and I have) built XSLTs that replace parts of strings using substring-before() and substring-after(). This method could become very complicated if not designed well.
XPath 2.0 includes additional string functions (e.g. regex) which would make this task very easy. Unfortunately, you would need to compile Cocoon (and Lenya) with a different XSL processor. I have not tried this, but remember reading about someone using Saxon. The Cocoon mindset is to create an InputModule that translates the string in the XMAP before passing to the XSLT. The URLEncodeModule is not what you want because slashes, colons, etc. are "safe" and not translated. A RegexInputModule would make things too easy so nobody has written it. You could create your own InputModule -- start with something simple like the RequestAttributeModule and only override the getAttribute function. I like XSPs, but they are rarely needed and their use is being discouraged. Converting your XSLT to an XSP is a design decision. I have not noticed any performance issues -- XSPs should be compiled on first use and run as fast as any Java code -- but I use very few XSPs. Other solutions might use a custom Generator or Transformer, JS Flow, or JXTemplates. If you like writing Java, I recommend a custom InputModule because little code is needed. If you are expert with XSL, a pure XSL solution might be best. HTH, solprovider On 4/25/08, Milan Ježdík <[EMAIL PROTECTED]> wrote: > According to this: > http://solprovider.com/lenya/variableshowto I am able to > put the parameters into my page (ad 1). Using > {page-envelop:document-url-without-language}. > > I still don't know how to convert special chars into HEX entities (ad 2). > So I still need help with creating the encoded article URL for bookmark > services (Exactly how to produce this: > http%3A%2F%2Flenya.apache.org%2Fscreenshots.html > from this: > http://lenya.apache.org/screenshots.html ? > > I was thinking about using XSP to do this but I am afraid about the site > performance. > > M. > > Milan Ježdík wrote: > > I would like to have "Share me" box on each article. This box will contain > a list of links to bookmark services such as digg, facebook, delicious, etc. > directly bookmarking this article. (example: > http://digg.com/submit?phase=2&url=http%3A%2F%2Flenya.apache.org%2Fscreenshots.html&title=Lenya+Apache+org) > > > > Questions: > > 1) How can I achieve this? > > 2) How can I convert special chars into HEX encoding? Eg. ':' -> %3A '/' > -> %2F, etc. > > > > I was thinking about using variables such {page-envelope:context-prefix}. > I just don't know if I can use (and how/where) these in XSL templates. > > > > Is this possible with changes only in XSL templates under xslt directory > or it needs some xmap changes? > > > > Any help appreciated. > > Thanks, > > Milan