Skip to content

Instantly share code, notes, and snippets.

@Tingenek
Created April 14, 2013 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tingenek/5383214 to your computer and use it in GitHub Desktop.
Save Tingenek/5383214 to your computer and use it in GitHub Desktop.
Cascaded selects followed by assembly into a new instance for submission
<processes>
<!-- Process for A -->
<process id="id-process-A">
<!-- Pipelines for A -->
<pipelines>
<pipeline id="id-pipeline-A1">
<cmdlines>
<cmdline id="id-cmdline1-fo-a-and-b">
<!-- Command line for A FO -->
</cmdline>
<cmdline id="id-cmdline2-fo-a-and-b">
<!-- Command line for A and B -->
</cmdline>
</cmdlines>
</pipeline>
</pipelines>
</process>
</processes>
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/resources/xsltforms/xsltforms.xsl" type="text/xsl"?>
<?xsltforms-options debug="no"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xf="http://www.w3.org/2002/xforms">
<head>
<style type="text/css">
.code {
font-family: monospace;
white-space: pre;
}
</style>
<title>Test</title>
<xf:model>
<!-- Temp data from the selections -->
<xf:instance id="scratchpad">
<data xmlns="">
<theprocess />
<thepipeline />
<thecmds />
</data>
</xf:instance>
<!-- Target for built process -->
<xf:instance id="mytarget">
<data xmlns="">
<processes>
</processes>
</data>
</xf:instance>
<!-- Source Data -->
<xf:instance id="mysource" src="process.xml" />
<!-- Set the list defaults to be first values in process.xml -->
<xf:action ev:event="xforms-ready">
<xf:setvalue ref="theprocess" value="instance('mysource')/process[1]/@id" />
<xf:setvalue ref="thepipeline"
value="instance('mysource')/process[1]/pipelines/pipeline[1]/@id" />
<xf:setvalue ref="thecmds"
value="instance('mysource')/process[1]/pipelines/pipeline[1]/cmdlines/cmdline[1]/@id" />
</xf:action>
</xf:model>
</head>
<body>
<h3>Pick Something</h3>
<!-- I know, I'm going to hell for using a table, not css. -->
<table>
<tr><td>
<!-- Process -->
<fieldset>
<legend>Process</legend>
<xf:select1 appearance="compact" incremental="false" ref="theprocess">
<xf:itemset nodeset="instance('mysource')/process">
<xf:label ref="@id" />
<xf:value ref="@id" />
</xf:itemset>
</xf:select1>
</fieldset>
</td>
<td>
<!-- Pipeline -->
<fieldset>
<legend>Pipeline</legend>
<xf:select1 appearance="compact" incremental="false" ref="thepipeline">
<xf:itemset
nodeset="instance('mysource')/process[@id = instance('scratchpad')/theprocess]/pipelines/pipeline">
<xf:label ref="@id" />
<xf:value ref="@id" />
</xf:itemset>
</xf:select1>
</fieldset>
</td><td>
<!-- Commands -->
<fieldset>
<legend>Commands</legend>
<xf:select1 appearance="compact" incremental="false" ref="thecmds">
<xf:itemset
nodeset="instance('mysource')/process[@id = instance('scratchpad')/theprocess]/pipelines/pipeline[@id = instance('scratchpad')/thepipeline]/cmdlines/cmdline">
<xf:label ref="@id" />
<xf:value ref="@id" />
</xf:itemset>
</xf:select1>
</fieldset>
</td>
</tr>
</table>
<xf:trigger>
<xf:label>Build Me!</xf:label>
<xf:action ev:event="DOMActivate">
<xf:delete nodeset="instance('mytarget')/processes/process"/>
<xf:insert context="instance('mytarget')/processes"
origin="instance('mysource')/process[@id = instance('scratchpad')/theprocess]" />
<xf:delete nodeset="instance('mytarget')/processes/process[1]/pipelines/pipeline[@id != instance('scratchpad')/thepipeline]" />
<xf:delete nodeset="instance('mytarget')/processes/process[1]/pipelines/pipeline[1]/cmdlines/cmdline[@id != instance('scratchpad')/thecmds]" />
<!-- your xf:send would go here :-) -->
</xf:action>
</xf:trigger>
<hr/>
<p class="code">
<xf:output value="serialize(instance('mytarget'),'yes')" />
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment