Skip to content

Instantly share code, notes, and snippets.

@sardinecan
Created April 10, 2019 13:03
Show Gist options
  • Save sardinecan/eec92d71de0f76952b31a64a3a096c14 to your computer and use it in GitHub Desktop.
Save sardinecan/eec92d71de0f76952b31a64a3a096c14 to your computer and use it in GitHub Desktop.
Repeat with external instances
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events">
<head>
<meta
charset="UTF-8"/>
<title>Copy Item</title>
<xf:model>
<xf:instance
id="xprMo">
<appendices
xmlns="">
<appendice/>
</appendices>
</xf:instance>
<xf:instance
id="xprTest">
<appendices
xmlns="">
<appendice>
<type/>
<type
type="test">test</type>
<type
type="other">other</type>
</appendice>
</appendices>
</xf:instance>
<xf:instance
id="xprOther">
<appendices
xmlns="">
<appendice>
<type/>
<type
type="other">other</type>
</appendice>
</appendices>
</xf:instance>
<xf:instance
id="type">
<type
xmlns=""/>
</xf:instance>
</xf:model>
</head>
<body>
<xf:repeat
nodeset="instance('xprMo')/appendice"
id="rApp">
<xf:select
ref="instance('xprTest')/appendice/type"
appearance="full">
<xf:label>Annexe</xf:label>
<xf:item>
<xf:label>test</xf:label>
<xf:value></xf:value>
<xf:action
ev:event="xforms-select">
<xf:insert
context="instance('xprMo')/appendice[index('rApp')]"
origin="instance('xprTest')/appendice/type[@type='test']"
ev:event="xforms-select"/>
</xf:action>
<xf:action
ev:event="xforms-deselect">
<xf:delete
ref="instance('xprMo')/appendice[index('rApp')]/type[@type='test']"
ev:event="xforms-deselect"/>
</xf:action>
</xf:item>
</xf:select>
<xf:select ref="instance('xprOther')/appendice/type"
appearance="full">
<xf:item>
<xf:label>other</xf:label>
<xf:value></xf:value>
<xf:action
ev:event="xforms-select">
<xf:insert
context="instance('xprMo')/appendice[index('rApp')]"
at="index('rApp')"
origin="instance('xprOther')/appendice/type[@type='other']"
ev:event="xforms-select"/>
</xf:action>
<xf:action
ev:event="xforms-deselect">
<xf:delete
ref="instance('xprMo')/appendice[index('rApp')]/type[@type='other']"
ev:event="xforms-deselect"/>
</xf:action>
</xf:item>
</xf:select>
<xf:input
ref="type[@type='other']"/>
</xf:repeat>
<xf:trigger>
<xf:label>ajouter</xf:label>
<xf:action
ev:event="DOMActivate">
<xf:insert
nodeset="appendice"
at="index('rApp')"
position="after"
ev:event="DOMActivate"/>
<xf:delete
ref="appendice[index('rApp')]/type[@type='test']"
ev:event="DOMActivate"/>
<xf:delete
ref="appendice[index('rApp')]/type[@type='other']"
ev:event="DOMActivate"/>
</xf:action>
</xf:trigger>
<div>
<pre>
<xf:output
value="serialize(., 'yes')"/>
</pre>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment