Last active
October 10, 2016 08:10
-
-
Save NKame/204cbcb4119b67f45525 to your computer and use it in GitHub Desktop.
Modification de la XSLT de génération d'un fichier GraphML à partir d'un fichier de dépendances issu de DependencyFinder, afin de pouvoir charger le fichier dans Tinkerpop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<!-- | |
Copyright (c) 2001-2009, Jean Tessier | |
All rights reserved. | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions | |
are met: | |
* Redistributions of source code must retain the above copyright | |
notice, this list of conditions and the following disclaimer. | |
* Redistributions in binary form must reproduce the above copyright | |
notice, this list of conditions and the following disclaimer in the | |
documentation and/or other materials provided with the distribution. | |
* Neither the name of Jean Tessier nor the names of his contributors | |
may be used to endorse or promote products derived from this software | |
without specific prior written permission. | |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR | |
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
--> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:strip-space elements="*"/> | |
<xsl:template match="dependencies"> | |
<graphml | |
xmlns="http://graphml.graphdrawing.org/xmlns" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"> | |
<graph edgedefault="directed"> | |
<key id="labelE" for="edge" attr.name="labelE" attr.type="string"></key> | |
<key id="labelV" for="node" attr.name="labelV" attr.type="string"></key> | |
<xsl:apply-templates select="//class | //feature"/> | |
<xsl:apply-templates select="//inbound"/> | |
</graph> | |
</graphml> | |
</xsl:template> | |
<xsl:template match="package"> | |
<node id="{name}"> | |
<data key="labelV"><xsl:value-of select="name" /></data> | |
</node> | |
<xsl:apply-templates/> | |
</xsl:template> | |
<xsl:template match="class | feature"> | |
<node id="{name}"> | |
<data key="labelV"><xsl:value-of select="name" /></data> | |
</node> | |
<edge id="{generate-id(.)}" source="{../name}" target="{name}"> | |
<data key="labelE">contains</data> | |
</edge> | |
<!-- <xsl:apply-templates/> --> | |
</xsl:template> | |
<xsl:template match="inbound"> | |
<edge id="{generate-id(.)}" source="{.}" target="{../name}"> | |
<data key="labelE"><xsl:value-of select="@type" /></data> | |
</edge> | |
</xsl:template> | |
<!-- | |
<xsl:template match="outbound"> | |
<edge id="{generate-id(.)}" source="{../name}" target="{.}"> | |
<data key="labelE"><xsl:value-of select="@type" /></data> | |
</edge> | |
</xsl:template> | |
--> | |
<xsl:template match="name"/> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Le problème principal reste que TinkerPop ne supporte pas l'absence d'attribut "id" sur les "edge", alors que la spéc GraphML précise bien que cet attribut est optionnel. Heureusement, grâce à Java 8, plus ça va plus le code de TinkerPop est illisible, bientôt on ne pourra même plus arriver à lire ce genre de détail dans le code.