Skip to content

Commit 294f0eb

Browse files
committed
Initial templates copied from examples directory of my WireIt fork.
0 parents  commit 294f0eb

File tree

9 files changed

+2122
-0
lines changed

9 files changed

+2122
-0
lines changed

README

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Steps2Wires.xsl -- run 'saxon -o:xproc-language.js typed-library.xml Steps2Wires.xsl' to generate xproc-language.js
2+
add_types2lib.xq -- run 'saxon-xquery' on this to generate a typed version of the standard step library from the W3C XML document.
3+
index.html
4+
typed-library.xml
5+
types.list -- set of all the types used in the options.
6+
types.xq
7+
xproc-language.js

Steps2Wires.xsl

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3+
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:p="http://www.w3.org/ns/xproc" xmlns:e="http://www.w3.org/1999/XSL/Spec/ElementSyntax"
4+
exclude-result-prefixes="xs p"
5+
version="2.0">
6+
<xsl:output method="text"/>
7+
<xsl:strip-space elements="*"/>
8+
9+
<xsl:template match="/">
10+
var xprocLanguage = {
11+
languageName: "XProc",
12+
propertiesFields: [
13+
{"type": "string", inputParams: {"name": "name", label: "Title", typeInvite: "Enter a title" } },
14+
{"type": "text", inputParams: {"name": "description", label: "Description", cols: 30} }
15+
],
16+
modules: [
17+
<xsl:apply-templates/>
18+
]
19+
};
20+
</xsl:template>
21+
22+
<xsl:template match="p:declare-step">
23+
{
24+
"name": "<xsl:value-of select="substring(@type,3)"/>",
25+
"container": {
26+
"xtype": "WireIt.FormContainer",
27+
"title": "<xsl:value-of select="@type"/>",
28+
"terminals": [
29+
<xsl:apply-templates select="p:input"/><xsl:if test="p:input and p:output">,</xsl:if>
30+
<xsl:apply-templates select="p:output"/>
31+
]
32+
<xsl:if test="p:option">, "fields": [
33+
<xsl:apply-templates select="p:option"/>
34+
]</xsl:if>
35+
}
36+
}<xsl:if test="position() != last()">,</xsl:if>
37+
</xsl:template>
38+
39+
<xsl:template match="p:input">
40+
{"name": "<xsl:value-of select="@port"/>", "direction": [0,-1], "offsetPosition":{"left": <xsl:value-of select="60 + 40 * position()"/>, "top": -15}, "ddConfig": { "type": "input", "allowedTypes": ["output"]} }<xsl:if test="position() != last()">,</xsl:if>
41+
</xsl:template>
42+
43+
<xsl:template match="p:output">
44+
{"name": "<xsl:value-of select="@port"/>", "direction": [0,1], "offsetPosition":{"left": <xsl:value-of select="60 + 40 * position()"/>, "bottom": -15}, "ddConfig": { "type": "output", "allowedTypes": ["input"]} }<xsl:if test="position() != last()">,</xsl:if>
45+
</xsl:template>
46+
47+
<xsl:template match="p:option">
48+
{<xsl:apply-templates mode="type" select="@e:type"/>"inputParams": {"label": "<xsl:value-of select="@name"/>"<xsl:apply-templates select="@select|@name|@required|@e:type[contains(., '|')]"/> } }<xsl:if test="position() != last()">,</xsl:if>
49+
</xsl:template>
50+
51+
<xsl:template match="@name|@required">, "<xsl:value-of select="name()"/>": "<xsl:value-of select="."/>"</xsl:template>
52+
53+
<!-- No quotes around booleans -->
54+
<xsl:template match="@select[../@e:type='xsd:boolean']">, "value": <xsl:value-of select="substring(., 2, string-length()-2)"/></xsl:template>
55+
<!-- Otherwise, quote the value -->
56+
<xsl:template match="@select">, "value": "<xsl:value-of select="substring(., 2, string-length()-2)"/>"</xsl:template>
57+
58+
<xsl:template match="@e:type[contains(.,'|')]">, "selectValues": [<xsl:value-of select="concat('''', replace(.,'\|', ''', '''), '''')"/>]</xsl:template>
59+
60+
<xsl:template mode="type" match="@e:type[.='xsd:boolean']">"type": "boolean", </xsl:template>
61+
<xsl:template mode="type" match="@e:type[.='xsd:integer']">"type": "integer", </xsl:template>
62+
<xsl:template mode="type" match="@e:type[.='xsd:anyURI']">"type": "url", </xsl:template>
63+
<xsl:template mode="type" match="@e:type[contains(.,'|')]">"type": "select", </xsl:template>
64+
<!-- Treat the other types as strings, don't leave a type signature: -->
65+
<xsl:template mode="type" match="@e:type"/>
66+
67+
</xsl:stylesheet>

add_types2lib.xq

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
declare namespace d="http://docbook.org/ns/docbook";
2+
declare namespace p="http://www.w3.org/ns/xproc";
3+
declare namespace e="http://www.w3.org/1999/XSL/Spec/ElementSyntax";
4+
<p:library xmlns="http://docbook.org/ns/docbook" xmlns:e="http://www.w3.org/1999/XSL/Spec/ElementSyntax"
5+
xmlns:xi="http://www.w3.org/2001/XInclude"
6+
xmlns:cs="http://www.w3.org/XML/XProc/2006/04/components#"
7+
xmlns:xlink="http://www.w3.org/1999/xlink" >{
8+
for $step in doc("http://www.w3.org/TR/xproc/langspec.xml")/id("std-components")/d:section/d:section/p:declare-step
9+
return $step
10+
}</p:library>

index.html

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2+
<html>
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5+
<title>WireIt - XProc Editor</title>
6+
<link rel="icon" href="../favicon.ico" type="image/png" />
7+
<link rel="SHORTCUT ICON" href="../favicon.ico" type="image/png" />
8+
9+
<!-- YUI -->
10+
<link rel="stylesheet" type="text/css" href="../../lib/yui/reset-fonts-grids/reset-fonts-grids.css" />
11+
<link rel="stylesheet" type="text/css" href="../../lib/yui/assets/skins/sam/skin.css" />
12+
13+
<!-- InputEx CSS -->
14+
<link type='text/css' rel='stylesheet' href='../../lib/inputex/css/inputEx.css' />
15+
16+
<!-- WireIt CSS -->
17+
<link rel="stylesheet" type="text/css" href="../../css/WireIt.css" />
18+
<link rel="stylesheet" type="text/css" href="../../css/WireItEditor.css" />
19+
20+
<style>
21+
div.WireIt-Container {
22+
width: 270px; /* Prevent the modules from scratching on the right */
23+
}
24+
div.WireIt-InputExTerminal {
25+
float: left;
26+
width: 21px;
27+
height: 21px;
28+
position: relative;
29+
}
30+
div.WireIt-InputExTerminal div.WireIt-Terminal {
31+
top: -3px;
32+
left: -7px;
33+
}
34+
div.inputEx-Group div.inputEx-label {
35+
width:100px;
36+
}
37+
38+
div.WireIt-ImageContainer {
39+
width: auto;
40+
}
41+
42+
.WiringEditor-module span {
43+
position: relative;
44+
top: -3px;
45+
}
46+
47+
div.WiringEditor-module-escape-markup {
48+
width: 340px;
49+
}
50+
51+
</style>
52+
53+
54+
<!-- YUI -->
55+
<script type="text/javascript" src="../../lib/yui/utilities/utilities.js"></script>
56+
<script type="text/javascript" src="../../lib/yui/resize/resize-min.js"></script>
57+
<script type="text/javascript" src="../../lib/yui/layout/layout-min.js"></script>
58+
<script type="text/javascript" src="../../lib/yui/container/container-min.js"></script>
59+
<script type="text/javascript" src="../../lib/yui/json/json-min.js"></script>
60+
<script type="text/javascript" src="../../lib/yui/button/button-min.js"></script>
61+
62+
<!-- YUI-RPC -->
63+
<script type="text/javascript" src="../../lib/yui-rpc.js"></script>
64+
65+
<!-- InputEx with wirable options (WirableField-beta) -->
66+
<script src="../../lib/inputex/js/inputex.js" type='text/javascript'></script>
67+
<script src="../../lib/inputex/js/Field.js" type='text/javascript'></script>
68+
<script type="text/javascript" src="../../js/util/inputex/WirableField-beta.js"></script>
69+
<script src="../../lib/inputex/js/Group.js" type='text/javascript'></script>
70+
<script src="../../lib/inputex/js/Visus.js" type='text/javascript'></script>
71+
<script src="../../lib/inputex/js/fields/StringField.js" type='text/javascript'></script>
72+
<script src="../../lib/inputex/js/fields/IntegerField.js" type='text/javascript'></script>
73+
<script src="../../lib/inputex/js/fields/Textarea.js" type='text/javascript'></script>
74+
<script src="../../lib/inputex/js/fields/SelectField.js" type='text/javascript'></script>
75+
<script src="../../lib/inputex/js/fields/EmailField.js" type='text/javascript'></script>
76+
<script src="../../lib/inputex/js/fields/UrlField.js" type='text/javascript'></script>
77+
<script src="../../lib/inputex/js/fields/ListField.js" type='text/javascript'></script>
78+
<script src="../../lib/inputex/js/fields/CheckBox.js" type='text/javascript'></script>
79+
<script src="../../lib/inputex/js/fields/InPlaceEdit.js" type='text/javascript'></script>
80+
81+
82+
<!-- WireIt -->
83+
<!--[if IE]><script type="text/javascript" src="../../lib/excanvas.js"></script><![endif]-->
84+
<script type="text/javascript" src="../../js/WireIt.js"></script>
85+
<script type="text/javascript" src="../../js/CanvasElement.js"></script>
86+
<script type="text/javascript" src="../../js/Wire.js"></script>
87+
<script type="text/javascript" src="../../js/Terminal.js"></script>
88+
<script type="text/javascript" src="../../js/util/DD.js"></script>
89+
<script type="text/javascript" src="../../js/util/DDResize.js"></script>
90+
<script type="text/javascript" src="../../js/Container.js"></script>
91+
<script type="text/javascript" src="../../js/Layer.js"></script>
92+
<script type="text/javascript" src="../../js/util/inputex/FormContainer-beta.js"></script>
93+
<script type="text/javascript" src="../../js/LayerMap.js"></script>
94+
<script type="text/javascript" src="../../js/WiringEditor.js"></script>
95+
<script type="text/javascript" src="../../js/ImageContainer.js"></script>
96+
97+
<script type="text/javascript" src="xproc-language.js"></script>
98+
99+
<script>
100+
101+
// InputEx needs a correct path to this image
102+
inputEx.spacerUrl = "/inputex/trunk/images/space.gif";
103+
104+
YAHOO.util.Event.onDOMReady( function() {
105+
var editor = new WireIt.WiringEditor(xprocLanguage);
106+
});
107+
</script>
108+
109+
</head>
110+
111+
<body class="yui-skin-sam">
112+
113+
<div id="top">
114+
<div class="logo">XProc</a></div>
115+
<div id="toolbar"></div>
116+
<div class="topright">
117+
<span>Hello there !</span> |
118+
<a href="../..">back to WireIt</a>
119+
</div>
120+
</div>
121+
122+
123+
<div id="left">
124+
</div>
125+
126+
<div id="right">
127+
<h2>Properties</h2>
128+
<div id="propertiesForm"></div>
129+
<h2>Minimap</h2>
130+
<div id="layerMap"></div>
131+
</div>
132+
133+
<div id="center">
134+
</div>
135+
136+
137+
<div id="helpPanel">
138+
<div class="hd">Welcome to the XProc Editor</div>
139+
<div class="bd" style="text-align: left;">
140+
141+
<p>This example shows how to use the <i>ImageContainer</i> and <i>FormContainer</i> in a language definition.</p>
142+
<br />
143+
<p><b>Drag and drop modules from the Module list</b> on the left to the working layer in the middle.</p>
144+
<br />
145+
<p><a href="demo.js" target="_new">Click here to view the language definition for this editor.</a></p>
146+
147+
</div>
148+
</div>
149+
150+
</body>
151+
</html>

0 commit comments

Comments
 (0)