mirror of
https://github.com/Quodatum/graphxq.git
synced 2025-04-11 11:42:24 +01:00
started
This commit is contained in:
parent
bfd2f26579
commit
2088ccd269
20 changed files with 1167 additions and 3 deletions
11
.project
Normal file
11
.project
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>graphxq</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
</natures>
|
||||
</projectDescription>
|
202
LICENSE
Normal file
202
LICENSE
Normal file
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -1,4 +1,4 @@
|
|||
graphxq
|
||||
=======
|
||||
# graphxq - interface to graphviz for BaseX 7.5
|
||||
|
||||
Basex restxq interface for Graphviz
|
||||
* includes dotML
|
||||
* BaseX RestXQ interface
|
||||
|
|
3
build/deploy
Executable file
3
build/deploy
Executable file
|
@ -0,0 +1,3 @@
|
|||
#/bin/sh
|
||||
cp -r src/* /home/andy/usr/basex/webapp/
|
||||
echo copied to /home/andy/usr/basex/webapp/
|
4
build/deploy-remote
Executable file
4
build/deploy-remote
Executable file
|
@ -0,0 +1,4 @@
|
|||
|
||||
rsync --verbose --progress --stats --compress \
|
||||
--recursive --times --perms --links --delete \
|
||||
src/* basex@velvet:~/webapp
|
117
src/graphxq.xqm
Normal file
117
src/graphxq.xqm
Normal file
|
@ -0,0 +1,117 @@
|
|||
(:~
|
||||
: restxq interface to graphviz
|
||||
: @author andy bunce
|
||||
: @since sept 2012
|
||||
:)
|
||||
|
||||
module namespace grxq = 'apb.graphviz.web';
|
||||
declare default function namespace 'apb.graphviz.web';
|
||||
import module namespace gr = 'apb.graphviz' at "graphxq/graphviz.xqm";
|
||||
declare namespace rest = 'http://exquery.org/ns/restxq';
|
||||
|
||||
declare
|
||||
%rest:GET %rest:path("graphxq")
|
||||
%output:method("html5")
|
||||
%rest:form-param("dot","{$dot}","")
|
||||
%rest:form-param("url","{$url}")
|
||||
function graphxq($dot,$url) {
|
||||
let $edot:=if($url) then "" else fn:encode-for-uri($dot)
|
||||
let $dot2:=getdot($dot,$url)
|
||||
let $svg:=get-svg($dot)
|
||||
return <html>
|
||||
<head>
|
||||
<title>Graphviz</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="tree xquery svg" />
|
||||
<script type="text/javascript"><![CDATA[
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-34544921-1']);
|
||||
_gaq.push(['_setDomainName', 'rhcloud.com']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
]]></script>
|
||||
<style type="text/css">pre {{background-color:#FFFFDD;}}</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>RestXQ interface to graphviz</h1>
|
||||
<p>Enter a string in the dot language
|
||||
Examples: <a href="?dot=digraph {{ a -> b}}">digraph {{ a -> b}}</a>,
|
||||
<a href="?hedge={{github|https://github.com/apb2006/hedgetree}}(ab({{tree|%23treexml}}))">another </a>
|
||||
.</p>
|
||||
<p> Or enter a Url to a xml document examples:
|
||||
<a href="?url=graphxq/samples/process.dot">process</a>,
|
||||
<a href="?url=hedgetree/samples/hier.dot">hedgeweb</a>
|
||||
<a href="?url=https://raw.github.com/apb2006/hedgetree/master/src/hedgetree/samples/hedgeweb.xml">remote</a>
|
||||
</p>
|
||||
<form method="get" action="./graphxq" style="background-color:#EEEEEE;padding:8px;">
|
||||
|
||||
|
||||
<textarea name="dot" rows="2" cols="80">{$dot}</textarea>
|
||||
<p></p>
|
||||
<p>Or enter the url to a node XML source
|
||||
<input name="url" value="{$url}" style="width:30em"/></p>
|
||||
<button type="submit">Redraw</button>
|
||||
</form >
|
||||
<h2 id="isvg">Inline SVG</h2>
|
||||
<div style="width:300px;height:200px">{$svg}</div>
|
||||
|
||||
<h2 id="svg">Object referencing <a href="graphxq/svg?dot={$edot}&url={$url}">svg</a>,
|
||||
( <a href="graphxq/svg?dl=1&dot={$edot}&url={$url}">download</a> svg)</h2>
|
||||
<object height="150" width="300" data="graphxq/svg?dot={$edot}&url={$url}"
|
||||
style="border:5px solid red;" type="image/svg+xml">
|
||||
SVG Here
|
||||
</object>
|
||||
<h2 id="svgxml">SVG xml</h2>
|
||||
<pre>
|
||||
{fn:serialize($svg)}
|
||||
</pre>
|
||||
|
||||
|
||||
<h2 id="layout">Layout xml</h2>
|
||||
|
||||
<h2>About</h2>
|
||||
<p> Source: @github:<iframe src="http://ghbtns.com/github-btn.html?user=apb2006&repo=graphxq&type=watch"
|
||||
allowtransparency="true" frameborder="0" scrolling="0" width="62px" height="20px"></iframe>, Twitter:
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-via="apb1704" data-count="none">Tweet</a>
|
||||
<script>!function(d,s,id){{var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){{js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}}}(document,"script","twitter-wjs");</script>.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
};
|
||||
|
||||
(:~ @return svg for hedge with download option.
|
||||
:)
|
||||
declare
|
||||
%rest:GET %rest:path("graphxq/svg")
|
||||
%rest:form-param("dot","{$dot}")
|
||||
%rest:form-param("url","{$url}")
|
||||
%rest:form-param("dl","{$dl}")
|
||||
function graphxq-svg($dot,$url,$dl) {
|
||||
let $dot2:=getdot($dot,$url)
|
||||
let $svg:=get-svg($dot2)
|
||||
let $down:=<rest:response>
|
||||
<http:response>
|
||||
<http:header name="Content-Disposition" value='attachment;filename="graphxq.svg"'/>
|
||||
</http:response>
|
||||
</rest:response>
|
||||
return ($down[$dl],$svg)
|
||||
};
|
||||
|
||||
(:~ use dot or url :)
|
||||
declare %private function getdot($dot,$url) as xs:string{
|
||||
if($url) then
|
||||
try{fn:unparsed-text(fn:resolve-uri($url))} catch * { "digraph {{ failed to load remote }}" }
|
||||
else
|
||||
$dot
|
||||
};
|
||||
(:~ post process svg :)
|
||||
declare %private function get-svg($dot as xs:string) as node(){
|
||||
let $svgx:=gr:dot($dot,())
|
||||
return gr:autosize($svgx)
|
||||
};
|
23
src/graphxq/dotml/.svn/all-wcprops
Normal file
23
src/graphxq/dotml/.svn/all-wcprops
Normal file
|
@ -0,0 +1,23 @@
|
|||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 39
|
||||
/apb/haveli/svn/!svn/ver/22/trunk/dotml
|
||||
END
|
||||
filters.svg
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 51
|
||||
/apb/haveli/svn/!svn/ver/22/trunk/dotml/filters.svg
|
||||
END
|
||||
dotpatch.xsl
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 52
|
||||
/apb/haveli/svn/!svn/ver/22/trunk/dotml/dotpatch.xsl
|
||||
END
|
||||
dotml2dot.xsl
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 53
|
||||
/apb/haveli/svn/!svn/ver/22/trunk/dotml/dotml2dot.xsl
|
||||
END
|
130
src/graphxq/dotml/.svn/entries
Normal file
130
src/graphxq/dotml/.svn/entries
Normal file
|
@ -0,0 +1,130 @@
|
|||
10
|
||||
|
||||
dir
|
||||
31
|
||||
https://free1.projectlocker.com/apb/haveli/svn/trunk/dotml
|
||||
https://free1.projectlocker.com/apb/haveli/svn
|
||||
|
||||
|
||||
|
||||
2010-05-05T15:00:02.461415Z
|
||||
22
|
||||
bunce.andy@gmail.com
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
fcc18bc9-29a6-4af3-8859-6d999b9301f9
|
||||
|
||||
filters.svg
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-03-06T15:01:30.000000Z
|
||||
e224c2cb06bf5c56caeeddf5198c6015
|
||||
2010-05-05T15:00:02.461415Z
|
||||
22
|
||||
bunce.andy@gmail.com
|
||||
has-props
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
4263
|
||||
|
||||
dotpatch.xsl
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-03-06T15:01:30.000000Z
|
||||
51115836e92588473c2f056c013f94ab
|
||||
2010-05-05T15:00:02.461415Z
|
||||
22
|
||||
bunce.andy@gmail.com
|
||||
has-props
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
6390
|
||||
|
||||
dotml2dot.xsl
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-03-06T15:01:30.000000Z
|
||||
42b23cbb9e04cae1e8eaa28ca39228da
|
||||
2010-05-05T15:00:02.461415Z
|
||||
22
|
||||
bunce.andy@gmail.com
|
||||
has-props
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
5556
|
||||
|
5
src/graphxq/dotml/.svn/prop-base/dotml2dot.xsl.svn-base
Normal file
5
src/graphxq/dotml/.svn/prop-base/dotml2dot.xsl.svn-base
Normal file
|
@ -0,0 +1,5 @@
|
|||
K 12
|
||||
svn:keywords
|
||||
V 23
|
||||
Id Date Author HeadURL
|
||||
END
|
5
src/graphxq/dotml/.svn/prop-base/dotpatch.xsl.svn-base
Normal file
5
src/graphxq/dotml/.svn/prop-base/dotpatch.xsl.svn-base
Normal file
|
@ -0,0 +1,5 @@
|
|||
K 12
|
||||
svn:keywords
|
||||
V 23
|
||||
Id Date Author HeadURL
|
||||
END
|
5
src/graphxq/dotml/.svn/prop-base/filters.svg.svn-base
Normal file
5
src/graphxq/dotml/.svn/prop-base/filters.svg.svn-base
Normal file
|
@ -0,0 +1,5 @@
|
|||
K 12
|
||||
svn:keywords
|
||||
V 23
|
||||
Id Date Author HeadURL
|
||||
END
|
83
src/graphxq/dotml/.svn/text-base/dotml2dot.xsl.svn-base
Normal file
83
src/graphxq/dotml/.svn/text-base/dotml2dot.xsl.svn-base
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
File dotml2dot.xsl
|
||||
Copyright 2002 - 2006 Martin Loetzsch
|
||||
Translates dotml documents into the native dot syntax.
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:dotml="http://www.martin-loetzsch.de/DOTML">
|
||||
<xsl:output method="text"/>
|
||||
<xsl:variable xml:space="preserve" name="graph-attributes">bgcolor fontcolor fontname fontsize label margin nodesep rankdir ranksep ratio size</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="cluster-attributes">bgcolor color fillcolor fontcolor fontname fontsize label labeljust labelloc style</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="node-attributes">color fillcolor fixedsize fontcolor fontname fontsize height shape style URL width</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="record-attributes">color fillcolor fontcolor fontname fontsize height style URL width</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="edge-attributes">arrowhead arrowsize arrowtail constraint color decorate dir fontcolor fontname fontsize headlabel headport label labeldistance labelfloat labelfontcolor labelfontname labelfontsize minlen samehead sametail style taillabel tailport URL</xsl:variable>
|
||||
<xsl:key name="nodes" match="//dotml:node" use="concat(@id,ancestor::dotml:graph/@file-name)"/>
|
||||
<xsl:template match="*" priority="-1000">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
<xsl:template match="text()"/>
|
||||
<xsl:template match="dotml:graph">digraph g {compound="true";<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="';'"/>
|
||||
<xsl:with-param name="attributes" select="$graph-attributes"/>
|
||||
</xsl:call-template>
|
||||
<xsl:apply-templates/>}
|
||||
<dot-filename><xsl:value-of select="@file-name"/></dot-filename>
|
||||
</xsl:template>
|
||||
<xsl:template match="dotml:sub-graph">subgraph sub_graph_<xsl:value-of select="count(preceding::dotml:sub-graph)"/>{rank="<xsl:value-of select="@rank"/>";<xsl:apply-templates/>}</xsl:template>
|
||||
<xsl:template match="dotml:cluster">subgraph cluster_<xsl:value-of select="@id"/>{<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="';'"/>
|
||||
<xsl:with-param name="attributes" select="$cluster-attributes"/>
|
||||
</xsl:call-template>
|
||||
<xsl:apply-templates/>}</xsl:template>
|
||||
<xsl:template match="dotml:node">node[label="<xsl:choose>
|
||||
<xsl:when test="@label">
|
||||
<xsl:value-of select="@label"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@id"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>", <xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="','"/>
|
||||
<xsl:with-param name="attributes" select="$node-attributes"/>
|
||||
</xsl:call-template>] {<xsl:value-of select="@id"/>};</xsl:template>
|
||||
<xsl:template match="dotml:edge">edge[<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="','"/>
|
||||
<xsl:with-param name="attributes" select="$edge-attributes"/>
|
||||
</xsl:call-template>lhead="<xsl:if test="@lhead">cluster_<xsl:value-of select="@lhead"/>
|
||||
</xsl:if>",ltail="<xsl:if test="@ltail">cluster_<xsl:value-of select="@ltail"/>
|
||||
</xsl:if>"] <xsl:if test="key('nodes',concat(@from,ancestor::dotml:graph/@file-name))/ancestor::dotml:record">struct<xsl:value-of select="count(key('nodes',concat(@from,ancestor::dotml:graph/@file-name))/preceding::dotml:record[local-name(..)!='record'])"/>:</xsl:if>
|
||||
<xsl:value-of select="@from"/> -> <xsl:if test="key('nodes',concat(@to,ancestor::dotml:graph/@file-name))/ancestor::dotml:record">struct<xsl:value-of select="count(key('nodes',concat(@to,ancestor::dotml:graph/@file-name))/preceding::dotml:record[local-name(..)!='record'])"/>:</xsl:if>
|
||||
<xsl:value-of select="@to"/>;</xsl:template>
|
||||
<xsl:template match="dotml:record">node[shape="record",label="<xsl:apply-templates select="dotml:*" mode="record-label"/>",<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="','"/>
|
||||
<xsl:with-param name="attributes" select="$record-attributes"/>
|
||||
</xsl:call-template>]{struct<xsl:value-of select="count(preceding::dotml:record[local-name(..)!='record'])"/>};</xsl:template>
|
||||
<xsl:template match="dotml:record" mode="record-label">{<xsl:apply-templates select="dotml:*" mode="record-label"/>}<xsl:if test="position()!=last()"> | </xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="dotml:node" mode="record-label"><<xsl:value-of select="@id"/>> <xsl:choose>
|
||||
<xsl:when test="@label">
|
||||
<xsl:value-of select="@label"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@id"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="position()!=last()"> | </xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template name="copy-attributes">
|
||||
<xsl:param name="attributes"/>
|
||||
<xsl:param name="separator"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(substring-after($attributes,' '))=0">
|
||||
<xsl:value-of select="$attributes"/>="<xsl:value-of select="@*[local-name()=$attributes]"/>"<xsl:value-of select="$separator"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before($attributes,' ')"/>="<xsl:value-of select="@*[local-name()=substring-before($attributes,' ')]"/>"<xsl:value-of select="$separator"/>
|
||||
<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="attributes" select="substring-after($attributes,' ')"/>
|
||||
<xsl:with-param name="separator" select="$separator"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
120
src/graphxq/dotml/.svn/text-base/dotpatch.xsl.svn-base
Normal file
120
src/graphxq/dotml/.svn/text-base/dotpatch.xsl.svn-base
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
tidy up graphviz svg o/p
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:haveli="http://apb.info">
|
||||
<xsl:param name="dotsrc" select="/.."/>
|
||||
<xsl:param name="filter">MyFilter</xsl:param>
|
||||
<xsl:param name="rotate" select="false()"/>
|
||||
<xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
|
||||
<xsl:template match="/svg:svg">
|
||||
<xsl:variable name="w" select="substring-before(@width,'px')"/>
|
||||
<xsl:variable name="h" select="substring-before(@height,'px')"/>
|
||||
<xsl:variable name="filters">
|
||||
<defs xmlns="http://www.w3.org/2000/svg">
|
||||
<filter id="Drop_Shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blurredAlpha"/>
|
||||
<feOffset in="blurredAlpha" dx="3" dy="3" result="offsetBlurredAlpha"/>
|
||||
<feFlood result="flooded" style="flood-color:rgb(0,0,0);flood-opacity:0.65"/>
|
||||
<feComposite in="flooded" operator="in" in2="offsetBlurredAlpha" result="coloredShadow"/>
|
||||
<feComposite in="SourceGraphic" in2="coloredShadow" operator="over"/>
|
||||
</filter>
|
||||
<filter id="Bevel" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="0.5" specularExponent="10" result="specOut" style="lighting-color:rgb(255,255,64)">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut2"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut2" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
</filter>
|
||||
<filter id="grey_bevel_shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur result="blurredAlpha" in="SourceAlpha" stdDeviation="3"/>
|
||||
<feOffset result="offsetBlurredAlpha" in="blurredAlpha" dx="2" dy="1"/>
|
||||
<feDiffuseLighting result="bumpMapDiffuse" in="blurredAlpha" surfaceScale="5" diffuseConstant="0.5" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite result="litPaint" in="bumpMapDiffuse" operator="arithmetic" k1="1" k2="0" k3="0" k4="0" in2="SourceGraphic"/>
|
||||
<feSpecularLighting result="bumpMapSpecular" in="blurredAlpha" surfaceScale="5" specularConstant="0.5" specularExponent="10" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite result="litPaint" in="litPaint" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" in2="bumpMapSpecular"/>
|
||||
<feComposite result="litPaint" in="litPaint" operator="in" in2="SourceAlpha"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlurredAlpha"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="Bumpy" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feTurbulence type="turbulence" baseFrequency="0.15" numOctaves="1" result="image0"/>
|
||||
<feGaussianBlur stdDeviation="3" in="image0" result="image1"/>
|
||||
<feDiffuseLighting in="image1" surfaceScale="10" diffuseConstant="1" result="image3" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="0" elevation="45"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite in="image3" in2="SourceGraphic" operator="arithmetic" k2="0.5" k3="0.5" result="image4"/>
|
||||
<feComposite in="image4" in2="SourceGraphic" operator="in" result="image5"/>
|
||||
</filter>
|
||||
<filter id="MyFilter" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<desc>Produces a 3D lighting effect suitable for pies and lines</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>
|
||||
<feOffset in="blur" dx="3" dy="5" result="offsetBlur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="1" specularExponent="30" style="lighting-color:White" result="specOut">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="MyShadow" filterUnits="objectBoundingBox" x="-20%" y="-20%" width="180%" height="180%">
|
||||
<desc>Simple blurred shadow (ideal for headings)</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="6" result="blur"/>
|
||||
<feOffset in="blur" dx="12" dy="10" result="offsetBlur"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="SourceGraphic"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
</defs>
|
||||
</xsl:variable>
|
||||
<svg width="100%" height="100%" preserveAspectRatio="xMidYMid meet" viewBox="0 0 {$w} {$h}" text-rendering="optimizeLegibility">
|
||||
<xsl:if test="$dotsrc">
|
||||
<haveli:dot>
|
||||
<xsl:value-of select="$dotsrc"/>
|
||||
</haveli:dot>
|
||||
</xsl:if>
|
||||
<xsl:copy-of select="$filters"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="rotate">
|
||||
<g transform="rotate(90 {$w div 2} {$h div 2} )">
|
||||
<xsl:call-template name="copy-content"/>
|
||||
</g>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="copy-content"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</svg>
|
||||
</xsl:template>
|
||||
<xsl:template name="copy-content">
|
||||
<xsl:apply-templates select="@*|processing-instruction()|*|text()"/>
|
||||
</xsl:template>
|
||||
<!--default behaviours for all nodes-->
|
||||
<xsl:template match="processing-instruction()|*|@*|text()">
|
||||
<xsl:copy>
|
||||
<xsl:call-template name="copy-content"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
<!-- apply non text in nodes -->
|
||||
<xsl:template match="svg:g[@class='node']">
|
||||
<g>
|
||||
<g filter="url(#{$filter})">
|
||||
<xsl:apply-templates select="*[local-name()!='text']"/>
|
||||
</g>
|
||||
<g>
|
||||
<xsl:apply-templates select="svg:text"/>
|
||||
</g>
|
||||
</g>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
71
src/graphxq/dotml/.svn/text-base/filters.svg.svn-base
Normal file
71
src/graphxq/dotml/.svn/text-base/filters.svg.svn-base
Normal file
|
@ -0,0 +1,71 @@
|
|||
|
||||
<!--
|
||||
filter defs
|
||||
-->
|
||||
|
||||
<defs xmlns="http://www.w3.org/2000/svg">
|
||||
<filter id="Drop_Shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blurredAlpha"/>
|
||||
<feOffset in="blurredAlpha" dx="3" dy="3" result="offsetBlurredAlpha"/>
|
||||
<feFlood result="flooded" style="flood-color:rgb(0,0,0);flood-opacity:0.65"/>
|
||||
<feComposite in="flooded" operator="in" in2="offsetBlurredAlpha" result="coloredShadow"/>
|
||||
<feComposite in="SourceGraphic" in2="coloredShadow" operator="over"/>
|
||||
</filter>
|
||||
<filter id="Bevel" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="0.5" specularExponent="10" result="specOut" style="lighting-color:rgb(255,255,64)">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut2"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut2" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
</filter>
|
||||
<filter id="grey_bevel_shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur result="blurredAlpha" in="SourceAlpha" stdDeviation="3"/>
|
||||
<feOffset result="offsetBlurredAlpha" in="blurredAlpha" dx="2" dy="1"/>
|
||||
<feDiffuseLighting result="bumpMapDiffuse" in="blurredAlpha" surfaceScale="5" diffuseConstant="0.5" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite result="litPaint" in="bumpMapDiffuse" operator="arithmetic" k1="1" k2="0" k3="0" k4="0" in2="SourceGraphic"/>
|
||||
<feSpecularLighting result="bumpMapSpecular" in="blurredAlpha" surfaceScale="5" specularConstant="0.5" specularExponent="10" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite result="litPaint" in="litPaint" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" in2="bumpMapSpecular"/>
|
||||
<feComposite result="litPaint" in="litPaint" operator="in" in2="SourceAlpha"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlurredAlpha"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="Bumpy" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feTurbulence type="turbulence" baseFrequency="0.15" numOctaves="1" result="image0"/>
|
||||
<feGaussianBlur stdDeviation="3" in="image0" result="image1"/>
|
||||
<feDiffuseLighting in="image1" surfaceScale="10" diffuseConstant="1" result="image3" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="0" elevation="45"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite in="image3" in2="SourceGraphic" operator="arithmetic" k2="0.5" k3="0.5" result="image4"/>
|
||||
<feComposite in="image4" in2="SourceGraphic" operator="in" result="image5"/>
|
||||
</filter>
|
||||
<filter id="MyFilter" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<desc>Produces a 3D lighting effect suitable for pies and lines</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>
|
||||
<feOffset in="blur" dx="3" dy="5" result="offsetBlur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="1" specularExponent="30" style="lighting-color:White" result="specOut">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="MyShadow" filterUnits="objectBoundingBox" x="-20%" y="-20%" width="180%" height="180%">
|
||||
<desc>Simple blurred shadow (ideal for headings)</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="6" result="blur"/>
|
||||
<feOffset in="blur" dx="12" dy="10" result="offsetBlur"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="SourceGraphic"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
</defs>
|
83
src/graphxq/dotml/dotml2dot.xsl
Normal file
83
src/graphxq/dotml/dotml2dot.xsl
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
File dotml2dot.xsl
|
||||
Copyright 2002 - 2006 Martin Loetzsch
|
||||
Translates dotml documents into the native dot syntax.
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:dotml="http://www.martin-loetzsch.de/DOTML">
|
||||
<xsl:output method="text"/>
|
||||
<xsl:variable xml:space="preserve" name="graph-attributes">bgcolor fontcolor fontname fontsize label margin nodesep rankdir ranksep ratio size</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="cluster-attributes">bgcolor color fillcolor fontcolor fontname fontsize label labeljust labelloc style</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="node-attributes">color fillcolor fixedsize fontcolor fontname fontsize height shape style URL width</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="record-attributes">color fillcolor fontcolor fontname fontsize height style URL width</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="edge-attributes">arrowhead arrowsize arrowtail constraint color decorate dir fontcolor fontname fontsize headlabel headport label labeldistance labelfloat labelfontcolor labelfontname labelfontsize minlen samehead sametail style taillabel tailport URL</xsl:variable>
|
||||
<xsl:key name="nodes" match="//dotml:node" use="concat(@id,ancestor::dotml:graph/@file-name)"/>
|
||||
<xsl:template match="*" priority="-1000">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
<xsl:template match="text()"/>
|
||||
<xsl:template match="dotml:graph">digraph g {compound="true";<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="';'"/>
|
||||
<xsl:with-param name="attributes" select="$graph-attributes"/>
|
||||
</xsl:call-template>
|
||||
<xsl:apply-templates/>}
|
||||
<dot-filename><xsl:value-of select="@file-name"/></dot-filename>
|
||||
</xsl:template>
|
||||
<xsl:template match="dotml:sub-graph">subgraph sub_graph_<xsl:value-of select="count(preceding::dotml:sub-graph)"/>{rank="<xsl:value-of select="@rank"/>";<xsl:apply-templates/>}</xsl:template>
|
||||
<xsl:template match="dotml:cluster">subgraph cluster_<xsl:value-of select="@id"/>{<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="';'"/>
|
||||
<xsl:with-param name="attributes" select="$cluster-attributes"/>
|
||||
</xsl:call-template>
|
||||
<xsl:apply-templates/>}</xsl:template>
|
||||
<xsl:template match="dotml:node">node[label="<xsl:choose>
|
||||
<xsl:when test="@label">
|
||||
<xsl:value-of select="@label"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@id"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>", <xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="','"/>
|
||||
<xsl:with-param name="attributes" select="$node-attributes"/>
|
||||
</xsl:call-template>] {<xsl:value-of select="@id"/>};</xsl:template>
|
||||
<xsl:template match="dotml:edge">edge[<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="','"/>
|
||||
<xsl:with-param name="attributes" select="$edge-attributes"/>
|
||||
</xsl:call-template>lhead="<xsl:if test="@lhead">cluster_<xsl:value-of select="@lhead"/>
|
||||
</xsl:if>",ltail="<xsl:if test="@ltail">cluster_<xsl:value-of select="@ltail"/>
|
||||
</xsl:if>"] <xsl:if test="key('nodes',concat(@from,ancestor::dotml:graph/@file-name))/ancestor::dotml:record">struct<xsl:value-of select="count(key('nodes',concat(@from,ancestor::dotml:graph/@file-name))/preceding::dotml:record[local-name(..)!='record'])"/>:</xsl:if>
|
||||
<xsl:value-of select="@from"/> -> <xsl:if test="key('nodes',concat(@to,ancestor::dotml:graph/@file-name))/ancestor::dotml:record">struct<xsl:value-of select="count(key('nodes',concat(@to,ancestor::dotml:graph/@file-name))/preceding::dotml:record[local-name(..)!='record'])"/>:</xsl:if>
|
||||
<xsl:value-of select="@to"/>;</xsl:template>
|
||||
<xsl:template match="dotml:record">node[shape="record",label="<xsl:apply-templates select="dotml:*" mode="record-label"/>",<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="','"/>
|
||||
<xsl:with-param name="attributes" select="$record-attributes"/>
|
||||
</xsl:call-template>]{struct<xsl:value-of select="count(preceding::dotml:record[local-name(..)!='record'])"/>};</xsl:template>
|
||||
<xsl:template match="dotml:record" mode="record-label">{<xsl:apply-templates select="dotml:*" mode="record-label"/>}<xsl:if test="position()!=last()"> | </xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="dotml:node" mode="record-label"><<xsl:value-of select="@id"/>> <xsl:choose>
|
||||
<xsl:when test="@label">
|
||||
<xsl:value-of select="@label"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@id"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="position()!=last()"> | </xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template name="copy-attributes">
|
||||
<xsl:param name="attributes"/>
|
||||
<xsl:param name="separator"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(substring-after($attributes,' '))=0">
|
||||
<xsl:value-of select="$attributes"/>="<xsl:value-of select="@*[local-name()=$attributes]"/>"<xsl:value-of select="$separator"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before($attributes,' ')"/>="<xsl:value-of select="@*[local-name()=substring-before($attributes,' ')]"/>"<xsl:value-of select="$separator"/>
|
||||
<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="attributes" select="substring-after($attributes,' ')"/>
|
||||
<xsl:with-param name="separator" select="$separator"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
121
src/graphxq/dotml/dotpatch.xsl
Normal file
121
src/graphxq/dotml/dotpatch.xsl
Normal file
|
@ -0,0 +1,121 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
tidy up graphviz svg o/p
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" >
|
||||
<xsl:param name="filter">MyFilter</xsl:param>
|
||||
<xsl:param name="rotate" select="false()"/>
|
||||
<xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
|
||||
<xsl:template match="/svg:svg">
|
||||
<xsl:variable name="w" select="substring-before(@width,'pt')"/>
|
||||
<xsl:variable name="aa" select="string(@width)"/>
|
||||
<xsl:variable name="h" select="substring-before(@height,'pt')"/>
|
||||
<xsl:variable name="filters">
|
||||
<defs xmlns="http://www.w3.org/2000/svg">
|
||||
<filter id="Drop_Shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blurredAlpha"/>
|
||||
<feOffset in="blurredAlpha" dx="3" dy="3" result="offsetBlurredAlpha"/>
|
||||
<feFlood result="flooded" style="flood-color:rgb(0,0,0);flood-opacity:0.65"/>
|
||||
<feComposite in="flooded" operator="in" in2="offsetBlurredAlpha" result="coloredShadow"/>
|
||||
<feComposite in="SourceGraphic" in2="coloredShadow" operator="over"/>
|
||||
</filter>
|
||||
<filter id="Bevel" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="0.5" specularExponent="10" result="specOut" style="lighting-color:rgb(255,255,64)">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut2"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut2" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
</filter>
|
||||
<filter id="grey_bevel_shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur result="blurredAlpha" in="SourceAlpha" stdDeviation="3"/>
|
||||
<feOffset result="offsetBlurredAlpha" in="blurredAlpha" dx="2" dy="1"/>
|
||||
<feDiffuseLighting result="bumpMapDiffuse" in="blurredAlpha" surfaceScale="5" diffuseConstant="0.5" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite result="litPaint" in="bumpMapDiffuse" operator="arithmetic" k1="1" k2="0" k3="0" k4="0" in2="SourceGraphic"/>
|
||||
<feSpecularLighting result="bumpMapSpecular" in="blurredAlpha" surfaceScale="5" specularConstant="0.5" specularExponent="10" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite result="litPaint" in="litPaint" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" in2="bumpMapSpecular"/>
|
||||
<feComposite result="litPaint" in="litPaint" operator="in" in2="SourceAlpha"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlurredAlpha"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="Bumpy" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feTurbulence type="turbulence" baseFrequency="0.15" numOctaves="1" result="image0"/>
|
||||
<feGaussianBlur stdDeviation="3" in="image0" result="image1"/>
|
||||
<feDiffuseLighting in="image1" surfaceScale="10" diffuseConstant="1" result="image3" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="0" elevation="45"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite in="image3" in2="SourceGraphic" operator="arithmetic" k2="0.5" k3="0.5" result="image4"/>
|
||||
<feComposite in="image4" in2="SourceGraphic" operator="in" result="image5"/>
|
||||
</filter>
|
||||
<filter id="MyFilter" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<desc>Produces a 3D lighting effect suitable for pies and lines</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>
|
||||
<feOffset in="blur" dx="3" dy="5" result="offsetBlur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="1" specularExponent="30" style="lighting-color:White" result="specOut">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="MyShadow" filterUnits="objectBoundingBox" x="-20%" y="-20%" width="180%" height="180%">
|
||||
<desc>Simple blurred shadow (ideal for headings)</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="6" result="blur"/>
|
||||
<feOffset in="blur" dx="12" dy="10" result="offsetBlur"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="SourceGraphic"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
</defs>
|
||||
</xsl:variable>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" aa="{$aa}"
|
||||
preserveAspectRatio="xMidYMid meet" viewBox="0 0 {$w} {$h}" text-rendering="optimizeLegibility">
|
||||
|
||||
<xsl:copy-of select="$filters"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="rotate">
|
||||
<g transform="rotate(90 {$w div 2} {$h div 2} )">
|
||||
<xsl:call-template name="copy-content"/>
|
||||
</g>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="*"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</svg>
|
||||
</xsl:template>
|
||||
<xsl:template name="copy-content">
|
||||
<xsl:apply-templates select="@*|processing-instruction()|*|text()"/>
|
||||
</xsl:template>
|
||||
<!--default behaviours for all nodes-->
|
||||
<xsl:template match="processing-instruction()|*|@*|text()">
|
||||
<xsl:copy>
|
||||
<xsl:call-template name="copy-content"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
<!-- apply non text in nodes -->
|
||||
<xsl:template match="svg:g[@class='node']">
|
||||
<g>
|
||||
<g filter="url(#{$filter})">
|
||||
<xsl:apply-templates select="*[local-name()!='text']"/>
|
||||
</g>
|
||||
<g>
|
||||
<xsl:apply-templates select="svg:text"/>
|
||||
</g>
|
||||
</g>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
71
src/graphxq/dotml/filters.svg
Normal file
71
src/graphxq/dotml/filters.svg
Normal file
|
@ -0,0 +1,71 @@
|
|||
|
||||
<!--
|
||||
filter defs
|
||||
-->
|
||||
|
||||
<defs xmlns="http://www.w3.org/2000/svg">
|
||||
<filter id="Drop_Shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blurredAlpha"/>
|
||||
<feOffset in="blurredAlpha" dx="3" dy="3" result="offsetBlurredAlpha"/>
|
||||
<feFlood result="flooded" style="flood-color:rgb(0,0,0);flood-opacity:0.65"/>
|
||||
<feComposite in="flooded" operator="in" in2="offsetBlurredAlpha" result="coloredShadow"/>
|
||||
<feComposite in="SourceGraphic" in2="coloredShadow" operator="over"/>
|
||||
</filter>
|
||||
<filter id="Bevel" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="0.5" specularExponent="10" result="specOut" style="lighting-color:rgb(255,255,64)">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut2"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut2" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
</filter>
|
||||
<filter id="grey_bevel_shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur result="blurredAlpha" in="SourceAlpha" stdDeviation="3"/>
|
||||
<feOffset result="offsetBlurredAlpha" in="blurredAlpha" dx="2" dy="1"/>
|
||||
<feDiffuseLighting result="bumpMapDiffuse" in="blurredAlpha" surfaceScale="5" diffuseConstant="0.5" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite result="litPaint" in="bumpMapDiffuse" operator="arithmetic" k1="1" k2="0" k3="0" k4="0" in2="SourceGraphic"/>
|
||||
<feSpecularLighting result="bumpMapSpecular" in="blurredAlpha" surfaceScale="5" specularConstant="0.5" specularExponent="10" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite result="litPaint" in="litPaint" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" in2="bumpMapSpecular"/>
|
||||
<feComposite result="litPaint" in="litPaint" operator="in" in2="SourceAlpha"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlurredAlpha"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="Bumpy" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feTurbulence type="turbulence" baseFrequency="0.15" numOctaves="1" result="image0"/>
|
||||
<feGaussianBlur stdDeviation="3" in="image0" result="image1"/>
|
||||
<feDiffuseLighting in="image1" surfaceScale="10" diffuseConstant="1" result="image3" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="0" elevation="45"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite in="image3" in2="SourceGraphic" operator="arithmetic" k2="0.5" k3="0.5" result="image4"/>
|
||||
<feComposite in="image4" in2="SourceGraphic" operator="in" result="image5"/>
|
||||
</filter>
|
||||
<filter id="MyFilter" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<desc>Produces a 3D lighting effect suitable for pies and lines</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>
|
||||
<feOffset in="blur" dx="3" dy="5" result="offsetBlur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="1" specularExponent="30" style="lighting-color:White" result="specOut">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="MyShadow" filterUnits="objectBoundingBox" x="-20%" y="-20%" width="180%" height="180%">
|
||||
<desc>Simple blurred shadow (ideal for headings)</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="6" result="blur"/>
|
||||
<feOffset in="blur" dx="12" dy="10" result="offsetBlur"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="SourceGraphic"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
</defs>
|
67
src/graphxq/graphviz.xqm
Normal file
67
src/graphxq/graphviz.xqm
Normal file
|
@ -0,0 +1,67 @@
|
|||
(:~
|
||||
: graphviz module
|
||||
: based on http://www.zorba-xquery.com/html/modules/zorba/image/graphviz
|
||||
:)
|
||||
|
||||
module namespace gr="apb.graphviz";
|
||||
declare default function namespace 'apb.graphviz';
|
||||
import module namespace proc="http://basex.org/modules/proc";
|
||||
import module namespace file="http://expath.org/ns/file";
|
||||
import module namespace xslt="http://basex.org/modules/xslt";
|
||||
|
||||
declare namespace svg= "http://www.w3.org/2000/svg";
|
||||
declare namespace xlink="http://www.w3.org/1999/xlink";
|
||||
|
||||
declare %private variable $gr:dotpath:=if(fn:environment-variable("DOTPATH"))
|
||||
then fn:environment-variable("DOTPATH")
|
||||
else "dot";
|
||||
(:~
|
||||
: folder for temp files
|
||||
:)
|
||||
declare %private variable $gr:tmpdir:=if(fn:environment-variable("TEMP"))
|
||||
then fn:environment-variable("TEMP")
|
||||
else "/tmp";
|
||||
|
||||
declare %private variable $gr:empty:=
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 20" version="1.1"
|
||||
width="100%" height="100%" preserveAspectRatio="xMidYMid meet">
|
||||
<text x="150" y="10" text-anchor="middle">Empty.</text>
|
||||
</svg>;
|
||||
|
||||
(:~
|
||||
:Layout one or more graphs given in the DOT language and render them as SVG.
|
||||
:)
|
||||
declare function dot( $dot as xs:string*, $params as xs:string*) as node()*{
|
||||
for $d in $dot
|
||||
return if($d)
|
||||
then dot1($d)
|
||||
else $gr:empty
|
||||
};
|
||||
|
||||
declare %private function dot1( $dot as xs:string) as node(){
|
||||
let $fname:=$gr:tmpdir || file:dir-separator() || random:uuid()
|
||||
let $junk:=file:write-text($fname,$dot)
|
||||
let $r:=proc:execute($gr:dotpath , ("-Tsvg",$fname))
|
||||
let $junk:=file:delete($fname)
|
||||
|
||||
return if($r/code="0")
|
||||
then fn:parse-xml($r/output)
|
||||
else fn:error()
|
||||
};
|
||||
(:~
|
||||
:Layout one ore more graphs given in the GXL language and render them as SVG.
|
||||
: gxl2dot Test.gxl > Test.dot
|
||||
:)
|
||||
declare function gxl($gxl as node()*, $params as xs:string*) as node()*{
|
||||
for $g in $gxl
|
||||
(: @TODO :)
|
||||
return fn:error()
|
||||
};
|
||||
|
||||
(:~
|
||||
: set svg to autosize 100%
|
||||
:)
|
||||
declare function autosize($svg as node()) as node(){
|
||||
xslt:transform($svg , fn:resolve-uri("dotml/dotpatch.xsl"))
|
||||
};
|
||||
|
16
src/graphxq/samples/hier.dot
Normal file
16
src/graphxq/samples/hier.dot
Normal file
|
@ -0,0 +1,16 @@
|
|||
digraph hierarchy_of_D {
|
||||
|
||||
node [color=Green,fontcolor=Blue,font=Courier]
|
||||
|
||||
B -> D
|
||||
C -> D
|
||||
|
||||
{rank=same; B C }
|
||||
|
||||
A -> B
|
||||
|
||||
A -> C
|
||||
|
||||
object -> A
|
||||
|
||||
}
|
27
src/graphxq/samples/process.dot
Normal file
27
src/graphxq/samples/process.dot
Normal file
|
@ -0,0 +1,27 @@
|
|||
digraph process {
|
||||
|
||||
subgraph cluster_0 {
|
||||
style=filled;
|
||||
color=lightgrey;
|
||||
node [style=filled,color=white];
|
||||
a0 -> a1 -> a2 -> a3;
|
||||
label = "process #1";
|
||||
}
|
||||
|
||||
subgraph cluster_1 {
|
||||
node [style=filled];
|
||||
b0 -> b1 -> b2 -> b3;
|
||||
label = "process #2";
|
||||
color=blue
|
||||
}
|
||||
start -> a0;
|
||||
start -> b0;
|
||||
a1 -> b3;
|
||||
b2 -> a3;
|
||||
a3 -> a0;
|
||||
a3 -> end;
|
||||
b3 -> end;
|
||||
|
||||
start [shape=Mdiamond];
|
||||
end [shape=Msquare];
|
||||
}
|
Loading…
Add table
Reference in a new issue