Starting to implement a version based on Orbeon's XPL or the archiver.
This commit is contained in:
parent
0424eedb2e
commit
c71d5b202d
|
@ -0,0 +1,328 @@
|
||||||
|
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://saxon.sf.net/">
|
||||||
|
|
||||||
|
<p:param name="data" type="input"/>
|
||||||
|
|
||||||
|
<!-- Fetch the resource -->
|
||||||
|
<p:processor name="oxf:url-generator">
|
||||||
|
<p:input name="config" transform="oxf:xslt" href="#data">
|
||||||
|
<config xsl:version="2.0">
|
||||||
|
<url>
|
||||||
|
<xsl:value-of select="/action/@url"/>
|
||||||
|
</url>
|
||||||
|
<header>
|
||||||
|
<name>User-Agent</name>
|
||||||
|
<value>
|
||||||
|
<xsl:value-of select="doc('oxf:/config.xml')/config/user-agent"/>
|
||||||
|
</value>
|
||||||
|
</header>
|
||||||
|
<mode>archive</mode>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="archive" debug="archive"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Store the archive in the database -->
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="data-access.xpl"/>
|
||||||
|
<p:input name="data" transform="oxf:xslt" href="#data">
|
||||||
|
<config xsl:version="2.0">
|
||||||
|
<relpath>
|
||||||
|
<xsl:value-of select="/action/@directory"/>
|
||||||
|
<xsl:value-of select="/action/@filename"/>
|
||||||
|
</relpath>
|
||||||
|
<operation>write</operation>
|
||||||
|
<type>document</type>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="param" href="#archive"/>
|
||||||
|
<p:output name="data" id="response2"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<p:processor name="oxf:null-serializer">
|
||||||
|
<p:input name="data" href="#response2"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Test the type of document to see if it needs to be rewritten -->
|
||||||
|
<p:choose href="#archive">
|
||||||
|
|
||||||
|
<!-- HTML document : need to update the links... -->
|
||||||
|
<p:when test="/archive/response/document/@content-type='text/html'">
|
||||||
|
|
||||||
|
<!-- Store the document -->
|
||||||
|
<p:processor name="oxf:file-serializer">
|
||||||
|
<p:input name="config">
|
||||||
|
<config>
|
||||||
|
<scope>session</scope>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="data" href="#archive#xpointer(/archive/response/document)"/>
|
||||||
|
<p:output name="data" id="url-written"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<!-- And read it as HTML -->
|
||||||
|
<p:processor name="oxf:url-generator">
|
||||||
|
<p:input name="config" transform="oxf:xslt" href="#url-written">
|
||||||
|
<config xsl:version="2.0">
|
||||||
|
<url>
|
||||||
|
<xsl:value-of select="/*"/>
|
||||||
|
</url>
|
||||||
|
<mode>html</mode>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="html" debug="html"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<!-- Get a list of links to update -->
|
||||||
|
<p:processor name="oxf:unsafe-xslt">
|
||||||
|
<p:input name="data" href="#html"/>
|
||||||
|
<p:input name="request" href="#archive#xpointer(/archive/request)"/>
|
||||||
|
<p:input name="config">
|
||||||
|
<xsl:stylesheet version="2.0">
|
||||||
|
<xsl:variable name="base" select="doc('input:request')/request/location"/>
|
||||||
|
<xsl:template match="/">
|
||||||
|
<links>
|
||||||
|
<xsl:variable name="links" as="node()*">
|
||||||
|
<xsl:apply-templates/>
|
||||||
|
</xsl:variable>
|
||||||
|
<xsl:for-each-group select="$links" group-by="@href">
|
||||||
|
<xsl:variable name="abs-href" select="resolve-uri(@href, $base)"/>
|
||||||
|
<xsl:variable name="tokens" select="tokenize($abs-href, '/')"/>
|
||||||
|
<xsl:variable name="last-token" select="$tokens[last()]"/>
|
||||||
|
<xsl:message>
|
||||||
|
<xsl:value-of select="$last-token"/>
|
||||||
|
</xsl:message>
|
||||||
|
<xsl:variable name="tokens2" select="tokenize($last-token, '\.')"/>
|
||||||
|
<xsl:variable name="extension" select="$tokens2[last()]"/>
|
||||||
|
<link abs-href="{$abs-href}" new-href="{saxon:string-to-hexBinary(substring($abs-href, 1, string-length($abs-href) - string-length($extension) - 1), 'utf-8')}.{$extension}"
|
||||||
|
filename="{saxon:string-to-hexBinary($abs-href, 'utf-8')}.xml">
|
||||||
|
<xsl:copy-of select="@*"/>
|
||||||
|
</link>
|
||||||
|
</xsl:for-each-group>
|
||||||
|
</links>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="text()"/>
|
||||||
|
<xsl:template match="link[@rel='stylesheet']">
|
||||||
|
<link>
|
||||||
|
<xsl:copy-of select="@*"/>
|
||||||
|
</link>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="img">
|
||||||
|
<link href="{@src}" type="image/*"/>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="script[@src]">
|
||||||
|
<link href="{@src}" type="{@type}"/>
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="links" debug="links"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<!-- Update the links -->
|
||||||
|
<p:processor name="oxf:unsafe-xslt">
|
||||||
|
<p:input name="data" href="#html"/>
|
||||||
|
<p:input name="request" href="#archive#xpointer(/archive/request)"/>
|
||||||
|
<p:input name="links" href="#links"/>
|
||||||
|
<p:input name="config">
|
||||||
|
<xsl:stylesheet version="2.0">
|
||||||
|
<xsl:variable name="links" select="doc('input:links')/links"/>
|
||||||
|
<xsl:variable name="base" select="doc('input:request')/request/location"/>
|
||||||
|
<xsl:key name="link" match="link" use="@href"/>
|
||||||
|
<xsl:template match="@*|node()">
|
||||||
|
<xsl:copy>
|
||||||
|
<xsl:apply-templates select="@*|node()"/>
|
||||||
|
</xsl:copy>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="link[@rel='stylesheet']/@href|img/@src|script/@src">
|
||||||
|
<xsl:attribute name="{name(.)}">
|
||||||
|
<xsl:value-of select="$links/key('link', current())/@new-href"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="link[@rel!='stylesheet']/@href|a/@href">
|
||||||
|
<xsl:attribute name="{name(.)}">
|
||||||
|
<xsl:value-of select="resolve-uri(., $base)"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="rewritten" debug="rewritten"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<!-- Store the rewritten document in the database -->
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="data-access.xpl"/>
|
||||||
|
<p:input name="data" transform="oxf:xslt" href="#data">
|
||||||
|
<config xsl:version="2.0">
|
||||||
|
<relpath>
|
||||||
|
<xsl:value-of select="/action/@directory"/>
|
||||||
|
<xsl:text>rewritten-</xsl:text>
|
||||||
|
<xsl:value-of select="/action/@filename"/>
|
||||||
|
</relpath>
|
||||||
|
<operation>write</operation>
|
||||||
|
<type>document</type>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="param" href="#rewritten"/>
|
||||||
|
<p:output name="data" id="response3"/>
|
||||||
|
</p:processor>
|
||||||
|
<p:processor name="oxf:null-serializer">
|
||||||
|
<p:input name="data" href="#response3"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Update the archive index -->
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="data-access.xpl"/>
|
||||||
|
<p:input name="data" transform="oxf:xslt" href="#data">
|
||||||
|
<config xsl:version="2.0">
|
||||||
|
<relpath>
|
||||||
|
<xsl:value-of select="/action/@directory"/>
|
||||||
|
<xsl:text>index.xml</xsl:text>
|
||||||
|
</relpath>
|
||||||
|
<operation>write</operation>
|
||||||
|
<type>xquery</type>
|
||||||
|
<parameter name="url" type="string">
|
||||||
|
<xsl:value-of select="/action/@url"/>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="filename" type="string">
|
||||||
|
<xsl:value-of select="/action/@filename"/>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="filename-rewritten" type="string">
|
||||||
|
<xsl:text>rewritten-</xsl:text>
|
||||||
|
<xsl:value-of select="/action/@filename"/>
|
||||||
|
</parameter>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="param">
|
||||||
|
<xquery><![CDATA[
|
||||||
|
for $as in /archive-set
|
||||||
|
return
|
||||||
|
update
|
||||||
|
insert <archive url=$(url) href=$(filename) href-rewritten=$(filename-rewritten)/>
|
||||||
|
into $as
|
||||||
|
]]></xquery>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="response1"/>
|
||||||
|
</p:processor>
|
||||||
|
<p:processor name="oxf:null-serializer">
|
||||||
|
<p:input name="data" href="#response1"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<!-- Update the queue -->
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="data-access.xpl"/>
|
||||||
|
<p:input name="data" transform="oxf:xslt" href="aggregate('root', #data, #links)">
|
||||||
|
<config xsl:version="2.0">
|
||||||
|
<relpath>queue.xml</relpath>
|
||||||
|
<operation>write</operation>
|
||||||
|
<type>xquery</type>
|
||||||
|
<parameter name="directory" type="string">
|
||||||
|
<xsl:value-of select="/root/action/@directory"/>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="uuid" type="string">
|
||||||
|
<xsl:value-of select="/root/action/@uuid"/>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="links" type="node-set">
|
||||||
|
<xsl:copy-of select="/root/links"/>
|
||||||
|
</parameter>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="param">
|
||||||
|
<xquery><![CDATA[
|
||||||
|
declare namespace util = "http://exist-db.org/xquery/util";
|
||||||
|
declare variable $links := $(links);
|
||||||
|
|
||||||
|
for $q in /queue return
|
||||||
|
update
|
||||||
|
insert
|
||||||
|
for $href in distinct-values($links/link/@abs-href)
|
||||||
|
let $link := $links/link[@abs-href = $href][1]
|
||||||
|
return <action uuid="{util:uuid()}" type="archive-resource" url="{$link/@abs-href}" directory=$(directory) filename="{$link/@filename}"/>
|
||||||
|
into $q,
|
||||||
|
|
||||||
|
for $a in /queue/action where $a/@uuid = $(uuid) return
|
||||||
|
update
|
||||||
|
delete $a
|
||||||
|
|
||||||
|
]]></xquery>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="response4" debug="response"/>
|
||||||
|
</p:processor>
|
||||||
|
<p:processor name="oxf:null-serializer">
|
||||||
|
<p:input name="data" href="#response4"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
|
||||||
|
</p:when>
|
||||||
|
|
||||||
|
<!-- Otherwise: no need to rewrite -->
|
||||||
|
<p:otherwise>
|
||||||
|
<!-- Update the archive index -->
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="data-access.xpl"/>
|
||||||
|
<p:input name="data" transform="oxf:xslt" href="#data">
|
||||||
|
<config xsl:version="2.0">
|
||||||
|
<relpath>
|
||||||
|
<xsl:value-of select="/action/@directory"/>
|
||||||
|
<xsl:text>index.xml</xsl:text>
|
||||||
|
</relpath>
|
||||||
|
<operation>write</operation>
|
||||||
|
<type>xquery</type>
|
||||||
|
<parameter name="url" type="string">
|
||||||
|
<xsl:value-of select="/action/@url"/>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="filename" type="string">
|
||||||
|
<xsl:value-of select="/action/@filename"/>
|
||||||
|
</parameter>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="param">
|
||||||
|
<xquery><![CDATA[
|
||||||
|
for $as in /archive-set
|
||||||
|
return
|
||||||
|
update
|
||||||
|
insert <archive url=$(url) href=$(filename)/>
|
||||||
|
into $as
|
||||||
|
]]></xquery>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="response1"/>
|
||||||
|
</p:processor>
|
||||||
|
<p:processor name="oxf:null-serializer">
|
||||||
|
<p:input name="data" href="#response1"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<!-- Update the queue -->
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="data-access.xpl"/>
|
||||||
|
<p:input name="data" transform="oxf:xslt" href="#data">
|
||||||
|
<config xsl:version="2.0">
|
||||||
|
<relpath>queue.xml</relpath>
|
||||||
|
<operation>write</operation>
|
||||||
|
<type>xquery</type>
|
||||||
|
<parameter name="uuid" type="string">
|
||||||
|
<xsl:value-of select="/action/@uuid"/>
|
||||||
|
</parameter>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="param">
|
||||||
|
<xquery><![CDATA[
|
||||||
|
|
||||||
|
for $a in /queue/action where $a/@uuid = $(uuid) return
|
||||||
|
update
|
||||||
|
delete $a
|
||||||
|
|
||||||
|
]]></xquery>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="response4" debug="response"/>
|
||||||
|
</p:processor>
|
||||||
|
<p:processor name="oxf:null-serializer">
|
||||||
|
<p:input name="data" href="#response4"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
</p:otherwise>
|
||||||
|
|
||||||
|
</p:choose>
|
||||||
|
|
||||||
|
</p:config>
|
|
@ -0,0 +1,89 @@
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Create a new archive
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||||
|
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:saxon="http://saxon.sf.net/" xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary">
|
||||||
|
|
||||||
|
<p:param name="data" type="input"/>
|
||||||
|
|
||||||
|
<p:processor name="oxf:unsafe-xslt">
|
||||||
|
<p:input name="data" href="#data"/>
|
||||||
|
<p:input name="config">
|
||||||
|
<config xsl:version="2.0">
|
||||||
|
<relpath>queue.xml</relpath>
|
||||||
|
<operation>write</operation>
|
||||||
|
<type>xquery</type>
|
||||||
|
<parameter name="directory" type="string">
|
||||||
|
<xsl:value-of select="translate(/action/@uuid, '-', '/')"/>
|
||||||
|
<xsl:text>/</xsl:text>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="filename" type="string">
|
||||||
|
<xsl:value-of select="saxon:string-to-hexBinary(/action/@url, 'utf-8')"/>
|
||||||
|
<xsl:text>.xml</xsl:text>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="uuid" type="string">
|
||||||
|
<xsl:value-of select="/action/@uuid"/>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="url" type="string">
|
||||||
|
<xsl:value-of select="/action/@url"/>
|
||||||
|
</parameter>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="data-access-data"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="data-access.xpl"/>
|
||||||
|
<p:input name="data" href="#data-access-data"/>
|
||||||
|
<p:input name="param">
|
||||||
|
<xquery><![CDATA[
|
||||||
|
declare namespace util = "http://exist-db.org/xquery/util";
|
||||||
|
|
||||||
|
for $q in /queue return
|
||||||
|
update
|
||||||
|
insert <action uuid="{util:uuid()}" type="archive-resource" url=$(url) directory=$(directory) filename=$(filename)/>
|
||||||
|
into $q,
|
||||||
|
|
||||||
|
for $a in /queue/action where $a/@uuid = $(uuid) return
|
||||||
|
update
|
||||||
|
delete $a
|
||||||
|
|
||||||
|
]]></xquery>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="response" debug="response"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<p:processor name="oxf:null-serializer">
|
||||||
|
<p:input name="data" href="#response"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="data-access.xpl"/>
|
||||||
|
<p:input name="data" transform="oxf:xslt" href="#data-access-data">
|
||||||
|
<config xsl:version="2.0">
|
||||||
|
<relpath>
|
||||||
|
<xsl:value-of select="/config/parameter[@name='directory']"/>
|
||||||
|
<xsl:text>index.xml</xsl:text>
|
||||||
|
</relpath>
|
||||||
|
<operation>write</operation>
|
||||||
|
<type>document</type>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="param" transform="oxf:xslt" href="#data">
|
||||||
|
<archive-set xsl:version="2.0">
|
||||||
|
<xsl:copy-of select="/action/@url|/action/@uuid"/>
|
||||||
|
</archive-set>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="response2" debug="response2"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<p:processor name="oxf:null-serializer">
|
||||||
|
<p:input name="data" href="#response2"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
|
||||||
|
</p:config>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<config>
|
||||||
|
|
||||||
|
<exist-root>http://admin@localhost:8080/orbeon/exist/rest/db/</exist-root>
|
||||||
|
<exist-db>owark/</exist-db>
|
||||||
|
|
||||||
|
<user-agent>Mozilla/5.0 (compatible; owark/0.3; http://owark.org/)</user-agent>
|
||||||
|
|
||||||
|
|
||||||
|
</config>
|
|
@ -0,0 +1,160 @@
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Database access
|
||||||
|
|
||||||
|
-->
|
||||||
|
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
|
xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:saxon="http://saxon.sf.net/">
|
||||||
|
|
||||||
|
|
||||||
|
<p:param name="param" type="input"/>
|
||||||
|
<!-- XQuery request or default document to read when not found -->
|
||||||
|
<p:param name="data" type="input"/>
|
||||||
|
<!-- Request description :
|
||||||
|
<config>
|
||||||
|
<relpath>Relatuve path</relpath>
|
||||||
|
<operation>read|write</operation>
|
||||||
|
<type>xquery|document</type>
|
||||||
|
<parameter></parameter>
|
||||||
|
<parameter></parameter>
|
||||||
|
</config>
|
||||||
|
-->
|
||||||
|
<p:param name="data" type="output"/>
|
||||||
|
|
||||||
|
|
||||||
|
<p:choose href="#data">
|
||||||
|
<p:when test="/config/type = 'document' and /config/operation='read'">
|
||||||
|
<p:processor name="oxf:xslt">
|
||||||
|
<p:input name="data" href="#data"/>
|
||||||
|
<p:input name="config.xml" href="oxf:/config.xml"/>
|
||||||
|
<p:input name="config">
|
||||||
|
<xsl:stylesheet version="2.0">
|
||||||
|
<xsl:template match="/">
|
||||||
|
<xsl:variable name="config" select="doc('input:config.xml')/config"/>
|
||||||
|
<xforms:submission method="get" replace="none" action="{$config/exist-root}{$config/exist-db}{/config/relpath}"/>
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="submission"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<p:processor name="oxf:xforms-submission">
|
||||||
|
<p:input name="submission" href="#submission"/>
|
||||||
|
<p:input name="request" href="#param"/>
|
||||||
|
<p:output name="response" id="document"/>
|
||||||
|
</p:processor>
|
||||||
|
<p:processor name="oxf:exception-catcher">
|
||||||
|
<p:input name="data" href="#document"/>
|
||||||
|
<p:output name="data" id="document-exception"/>
|
||||||
|
</p:processor>
|
||||||
|
<p:choose href="#document-exception">
|
||||||
|
<p:when test="/exceptions">
|
||||||
|
<p:processor name="oxf:identity">
|
||||||
|
<p:input name="data" href="#param"/>
|
||||||
|
<p:output name="data" ref="data"/>
|
||||||
|
</p:processor>
|
||||||
|
</p:when>
|
||||||
|
<p:otherwise>
|
||||||
|
<p:processor name="oxf:identity">
|
||||||
|
<p:input name="data" href="#document-exception"/>
|
||||||
|
<p:output name="data" ref="data"/>
|
||||||
|
</p:processor>
|
||||||
|
</p:otherwise>
|
||||||
|
</p:choose>
|
||||||
|
|
||||||
|
</p:when>
|
||||||
|
<p:when test="/config/type = 'document' and /config/operation='write'">
|
||||||
|
<p:processor name="oxf:xslt">
|
||||||
|
<p:input name="data" href="#data"/>
|
||||||
|
<p:input name="config.xml" href="oxf:/config.xml"/>
|
||||||
|
<p:input name="config">
|
||||||
|
<xsl:stylesheet version="2.0">
|
||||||
|
<xsl:template match="/">
|
||||||
|
<xsl:variable name="config" select="doc('input:config.xml')/config"/>
|
||||||
|
<xforms:submission method="put" replace="none" action="{$config/exist-root}{$config/exist-db}{/config/relpath}"/>
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="submission"/>
|
||||||
|
</p:processor>
|
||||||
|
<p:processor name="oxf:xforms-submission">
|
||||||
|
<p:input name="submission" href="#submission"/>
|
||||||
|
<p:input name="request" href="#param"/>
|
||||||
|
<p:output name="response" ref="data"/>
|
||||||
|
</p:processor>
|
||||||
|
</p:when>
|
||||||
|
|
||||||
|
<p:when test="/config/type = 'xquery' ">
|
||||||
|
|
||||||
|
<p:processor name="oxf:unsafe-xslt">
|
||||||
|
<p:input name="data" href="#data"/>
|
||||||
|
<p:input name="config.xml" href="oxf:/config.xml"/>
|
||||||
|
<p:input name="param" href="#param"/>
|
||||||
|
<p:input name="config">
|
||||||
|
<xsl:stylesheet version="2.0">
|
||||||
|
<xsl:output name="output" method="xml" omit-xml-declaration="yes"/>
|
||||||
|
<xsl:template match="/">
|
||||||
|
<xsl:variable name="query">
|
||||||
|
<xsl:variable name="data" select="/"/>
|
||||||
|
<xsl:analyze-string select="string(doc('input:param'))" regex="\$\((\i\c*)\)" flags="">
|
||||||
|
<xsl:matching-substring>
|
||||||
|
<xsl:variable name="parameter" select="$data/config/parameter[@name = regex-group(1)]"/>
|
||||||
|
<xsl:variable name="sanitized" select="if ($parameter/@type = 'node-set') then saxon:serialize($parameter/*, 'output') else replace(replace($parameter, '&', '&amp;'), '''', '&apos;')"/>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="not($parameter)">
|
||||||
|
<xsl:message terminate="yes">Parameter <xsl:value-of select="regex-group(1)"/> not found in query <xsl:value-of select="doc('input:param')"
|
||||||
|
/></xsl:message>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:when test="$parameter/@type='string'">
|
||||||
|
<xsl:text>'</xsl:text>
|
||||||
|
<xsl:value-of select="$sanitized"/>
|
||||||
|
<xsl:text>'</xsl:text>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:when test="$parameter/@type='node-set'">
|
||||||
|
<xsl:copy-of select="$sanitized"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="$parameter/@type"/>
|
||||||
|
<xsl:text>('</xsl:text>
|
||||||
|
<xsl:value-of select="$sanitized"/>
|
||||||
|
<xsl:text>')</xsl:text>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:matching-substring>
|
||||||
|
<xsl:non-matching-substring>
|
||||||
|
<xsl:value-of select="."/>
|
||||||
|
</xsl:non-matching-substring>
|
||||||
|
</xsl:analyze-string>
|
||||||
|
</xsl:variable>
|
||||||
|
<xsl:message>
|
||||||
|
<xsl:value-of select="$query"/>
|
||||||
|
</xsl:message>
|
||||||
|
<xsl:variable name="config" select="doc('input:config.xml')/config"/>
|
||||||
|
<xforms:submission method="get" replace="none"
|
||||||
|
action="{$config/exist-root}{$config/exist-db}{/config/relpath}?_howmany=10000&_query={encode-for-uri(normalize-space($query))}"/>
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="submission"/>
|
||||||
|
</p:processor>
|
||||||
|
<p:processor name="oxf:xforms-submission">
|
||||||
|
<p:input name="submission" href="#submission"/>
|
||||||
|
<p:input name="request" href="#param"/>
|
||||||
|
<p:output name="response" ref="data"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
</p:when>
|
||||||
|
|
||||||
|
<p:otherwise>
|
||||||
|
<p:processor name="oxf:identity">
|
||||||
|
<p:input name="data">
|
||||||
|
<not-implemented/>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" ref="data"/>
|
||||||
|
</p:processor>
|
||||||
|
</p:otherwise>
|
||||||
|
</p:choose>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</p:config>
|
|
@ -0,0 +1,65 @@
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Database creation
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||||
|
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary">
|
||||||
|
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="data-access.xpl"/>
|
||||||
|
<p:input name="data">
|
||||||
|
<config>
|
||||||
|
<relpath>index.xhtml</relpath>
|
||||||
|
<operation>write</operation>
|
||||||
|
<type>document</type>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="param">
|
||||||
|
<html xml:lang="fr" >
|
||||||
|
<head>
|
||||||
|
<title>Owark DB</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>Owark db</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="response" debug="response"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<p:processor name="oxf:null-serializer">
|
||||||
|
<p:input name="data" href="#response"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="data-access.xpl"/>
|
||||||
|
<p:input name="data">
|
||||||
|
<config>
|
||||||
|
<relpath>queue.xml</relpath>
|
||||||
|
<operation>write</operation>
|
||||||
|
<type>document</type>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="param">
|
||||||
|
<queue/>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="response2" debug="response2"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<p:processor name="oxf:null-serializer">
|
||||||
|
<p:input name="data" href="#response2"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Indexes -->
|
||||||
|
<!--<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="create-indexes.xpl"/>
|
||||||
|
</p:processor>
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
</p:config>
|
|
@ -0,0 +1,39 @@
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Post an archive request
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||||
|
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary">
|
||||||
|
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="data-access.xpl"/>
|
||||||
|
<p:input name="data">
|
||||||
|
<config>
|
||||||
|
<relpath>queue.xml</relpath>
|
||||||
|
<operation>write</operation>
|
||||||
|
<type>xquery</type>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="param">
|
||||||
|
<xquery><![CDATA[
|
||||||
|
declare namespace util = "http://exist-db.org/xquery/util";
|
||||||
|
|
||||||
|
for $q in /queue return
|
||||||
|
update
|
||||||
|
insert <action uuid="{util:uuid()}" type="archive-set" url="http://dyomedea.com"/>
|
||||||
|
into $q
|
||||||
|
|
||||||
|
]]></xquery>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="response" debug="response"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<p:processor name="oxf:null-serializer">
|
||||||
|
<p:input name="data" href="#response"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
|
||||||
|
</p:config>
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Reinstall the database
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||||
|
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary">
|
||||||
|
|
||||||
|
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="uninstall-db.xpl" />
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="install-db.xpl" />
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
|
||||||
|
</p:config>
|
|
@ -0,0 +1,53 @@
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Scheduler
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||||
|
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary">
|
||||||
|
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="data-access.xpl"/>
|
||||||
|
<p:input name="data">
|
||||||
|
<config>
|
||||||
|
<relpath>queue.xml</relpath>
|
||||||
|
<operation>read</operation>
|
||||||
|
<type>xquery</type>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="param">
|
||||||
|
<xquery><![CDATA[
|
||||||
|
|
||||||
|
/queue/action
|
||||||
|
|
||||||
|
]]></xquery>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="actions" debug="actions"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<p:for-each href="#actions" select="/*/action">
|
||||||
|
|
||||||
|
<p:processor name="oxf:url-generator">
|
||||||
|
<p:input name="config" transform="oxf:xslt" href="current()">
|
||||||
|
<config xsl:version="2.0">
|
||||||
|
<url>
|
||||||
|
<xsl:text>oxf:/</xsl:text>
|
||||||
|
<xsl:value-of select="/action/@type"/>
|
||||||
|
<xsl:text>.xpl</xsl:text>
|
||||||
|
</url>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="pipeline"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<p:processor name="oxf:pipeline">
|
||||||
|
<p:input name="config" href="#pipeline"/>
|
||||||
|
<p:input name="data" href="current()"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
</p:for-each>
|
||||||
|
|
||||||
|
|
||||||
|
</p:config>
|
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Remove the database
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
|
||||||
|
xmlns:oxf="http://www.orbeon.com/oxf/processors"
|
||||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||||
|
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
|
||||||
|
xmlns:exist="http://exist.sourceforge.net/NS/exist"
|
||||||
|
xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary">
|
||||||
|
|
||||||
|
<p:processor name="oxf:xforms-submission">
|
||||||
|
<p:input name="submission" href="oxf:/config.xml"
|
||||||
|
transform="oxf:xslt">
|
||||||
|
<xforms:submission xsl:version="2.0" method="delete"
|
||||||
|
action="{/config/exist-root}{/config/exist-db}"
|
||||||
|
/>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="request">
|
||||||
|
<empty/>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="response" id="response1"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<p:processor name="oxf:null-serializer">
|
||||||
|
<p:input name="data" href="#response1"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
|
||||||
|
</p:config>
|
Loading…
Reference in New Issue