Hi all, But I can't really test it because I'm getting other errors. What I would like to do in the page-flow is redirect the page "id/(.*)" to "id/$1.html" via a semantic 303 redirect. So I want to generate a small HTML doc that will be returned by curl, but if you visit "id/(.*) in a browser, the browser will automatically redirect. So there's some XSLT that must occur with, I think, the HTTP serializer on top of it to control the status code and header. But I'm getting the following error:I've been looking around the documentation for information about redirects. The HTTP serializer allows you to set the status code (I want to use 303 to redirect to another URI), but not the redirect location. I think I can use the header in oxf:http-serializer to do this: <header> <name>Location</name> <value>URI</value> </header> Root element must contain an xsi:type attribute <p:pipeline xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors"> <p:param type="input" name="data"/> <p:param type="output" name="data"/> <p:processor name="oxf:request"> <p:input name="config"> <config> <include>/request</include> </config> </p:input> <p:output name="data" id="request"/> </p:processor> <!-- generate HTML fragment to be returned --> <p:processor name="oxf:unsafe-xslt"> <p:input name="request" href="#request"/> <p:input name="data" href="../config.xml"/> <p:input name="config"> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:template match="/"> <xsl:variable name="path" select="substring-after(doc('input:request')/request/request-url, 'id/')"/> <html> <head> <title>303 See Other</title> </head> <body> <h1>See Other</h1> <p>The answer to your request is located <a href="{/config/url}id/{$path}.html">here</a>.</p> </body> </html> </xsl:template> </xsl:stylesheet> </p:input> <p:output name="data" id="converted"/> <p:output name="data" ref="data"/> </p:processor> <!-- generate config for http-serializer --> <p:processor name="oxf:unsafe-xslt"> <p:input name="request" href="#request"/> <p:input name="data" href="../config.xml"/> <p:input name="config"> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:template match="/"> <xsl:variable name="path" select="substring-after(doc('input:request')/request/request-url, 'id/')"/> <config> <status-code>303</status-code> <content-type>text/plain</content-type> <header> <name>Location</name> <value> <xsl:value-of select="concat(/config/url, 'id/', $path, '.html')"/> </value> </header> </config> </xsl:template> </xsl:stylesheet> </p:input> <p:output name="data" id="config"/> </p:processor> <p:processor name="oxf:http-serializer"> <p:input name="data" href="#converted"/> <p:input name="config" href="#config"/> </p:processor> </p:pipeline> Thanks, Ethan You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. |
Administrator
|
If you are fine with 302 (http://en.wikipedia.org/wiki/HTTP_302) instead of a 303, which assumes the browser does a GET, then you should be able to redirect from "id/(.*)" to "id/$1.html" just with the page flow. The section below illustrates how the page flow is not only able to extract parameters from URL to populate an XML document, but also to do the opposite, which is interesting when you want to redirect users between pages. Would something like that work for you?
http://wiki.orbeon.com/forms/doc/developer-guide/page-flow-controller#TOC-Navigating-to-pages-that-use-matchers Otherwise, I imagine you should indeed be able to do this by hand with the HTTP serializer. You should be pointing to the XPL with the model attribute (not view), and it should have no data output. If it doesn't work, you can maybe start by making everything static, just always issuing the same redirect, to check that part is working. Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
In reply to this post by Ethan Gruber
Hi Alex,
-- I got it working. Thanks! I'm working on a linked data application, so I needed to use 303 for its semantic meaning. I'm not very pedantic about HTTP, but others are, so I decided to play it by the book. I called the XPL in the model instead of view in the page-flow and removed the data outputs. Ethan On Friday, January 24, 2014 10:18:31 AM UTC-5, ewg4xuva wrote:
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. |
Free forum by Nabble | Edit this page |