Created
October 24, 2014 16:50
-
-
Save acspike/352ae483cf39cdc5233b to your computer and use it in GitHub Desktop.
orbeon test #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####################################### | |
# page-flow.xml | |
####################################### | |
<controller xmlns="http://www.orbeon.com/oxf/controller" matcher="regexp"> | |
<service public-methods="GET HEAD POST PUT" | |
path="/mlc/test" | |
model="test.xpl"/> | |
<page path="/mlc/page" | |
view="page.xhtml"/> | |
<!-- ==== Epilogue and handlers ================================================================================ --> | |
<!-- NOTE: Use top-level handlers --> | |
<epilogue url="oxf:/config/epilogue.xpl"/> | |
</controller> | |
####################################### | |
# page.xhtml | |
####################################### | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> | |
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script> | |
<script type="text/javascript"><![CDATA[ | |
var myfun = function(){ | |
var docstr = '<?xml version="1.0" encoding="UTF-8"?><foo><!-- this is a comment --><bar><!-- this is a comment2 -->Hello World</bar></foo>'; | |
$.ajax({ | |
url: '/orbeon/mlc/test', | |
processData: false, | |
type: "PUT", // type should be POST | |
data: docstr, // send the string directly | |
contentType: 'application/xml', | |
success: function(response){ | |
alert(response); | |
}, | |
error: function(response) { | |
alert(response); | |
} | |
}); | |
}; | |
]]></script> | |
</head> | |
<body> | |
<button type="button" onclick="myfun();">Click Me</button> | |
</body> | |
</html> | |
####################################### | |
# test.xpl | |
####################################### | |
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" | |
xmlns:sql="http://orbeon.org/oxf/xml/sql" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:oxf="http://www.orbeon.com/oxf/processors" | |
xmlns:xi="http://www.w3.org/2001/XInclude" | |
xmlns:xf="http://www.w3.org/2002/xforms" | |
xmlns:ev="http://www.w3.org/2001/xml-events" | |
xmlns:exist="http://exist.sourceforge.net/NS/exist" | |
xmlns:saxon="http://saxon.sf.net/" | |
xmlns:frf="java:org.orbeon.oxf.fr.FormRunner" | |
xmlns:xpl="java:org.orbeon.oxf.pipeline.api.FunctionLibrary"> | |
<p:param type="input" name="instance"/> | |
<p:processor name="oxf:identity"> | |
<p:input name="data" href="#instance" debug="yyyinstanceyyy"/> | |
<p:output name="data" id="instanceid"/> | |
</p:processor> | |
<!-- NOTE: It's disappointing that we have to use oxf:request/oxf:regexp rather than using the page flow | |
directly, but because we want to support the PUT and POST methods, this is currently the only solution. --> | |
<p:processor name="oxf:request"> | |
<p:input name="config"> | |
<config stream-type="xs:anyURI"> | |
<include>/request/request-path</include> | |
<include>/request/content-type</include> | |
<include>/request/method</include> | |
<include>/request/body</include> | |
<include>/request/headers/header[name = 'orbeon-exist-uri']</include> | |
<include>/request/headers/header[name = 'orbeon-username']</include> | |
<include>/request/headers/header[name = 'orbeon-group']</include> | |
</config> | |
</p:input> | |
<p:output name="data" id="request"/> | |
</p:processor> | |
<!-- Discriminate based on the HTTP method and content type --> | |
<p:choose href="#request"> | |
<!-- Handle binary and XML GET --> | |
<p:when test="/*/method = 'GET'"> | |
<p:processor name="oxf:identity"> | |
<p:input name="data" href="aggregate('root', #instanceid, #request)" /> | |
<p:output name="data" id="response" debug="xxxresponsezzz"/> | |
</p:processor> | |
</p:when> | |
<p:otherwise> | |
<!-- Discriminate based on the HTTP method and content type --> | |
<p:choose href="#request"> | |
<!-- XML PUT --> | |
<p:when test="/*/method = 'PUT'"> | |
<p:processor name="oxf:identity"> | |
<p:input name="data" href="aggregate('root', #instanceid, #request)" /> | |
<p:output name="data" id="response" debug="xxxresponseyyy"/> | |
</p:processor> | |
</p:when> | |
</p:choose> | |
</p:otherwise> | |
</p:choose> | |
<!-- Convert and serialize to XML --> | |
<p:processor name="oxf:xml-converter"> | |
<p:input name="config"> | |
<config> | |
<indent>false</indent> | |
<encoding>utf-8</encoding> | |
</config> | |
</p:input> | |
<p:input name="data" href="#response"/> | |
<p:output name="data" id="converted"/> | |
</p:processor> | |
<p:processor name="oxf:http-serializer"> | |
<p:input name="config"> | |
<config> | |
<cache-control> | |
<use-local-cache>false</use-local-cache> | |
</cache-control> | |
</config> | |
</p:input> | |
<p:input name="data" href="#converted"/> | |
</p:processor> | |
</p:config> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment