Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added TP2-to-TP3 GraphML XSLT to resources #501

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 40 additions & 0 deletions gremlin-core/src/main/resources/tp2-to-tp3-graphml.xslt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" ?>
<!-- XSL stylesheet to convert TinkerPop v2 GraphML files for Apache TinkerPop v3 -->
<xsl:stylesheet version="1.0"
xmlns="http://graphml.graphdrawing.org/xmlns"
xmlns:graphml="http://graphml.graphdrawing.org/xmlns"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="graphml">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>

<xsl:template match="graphml:graphml">
<graphml>
<key id="labelV" for="node" attr.name="labelV" attr.type="string"/>
<key id="labelE" for="edge" attr.name="labelE" attr.type="string"/>
<xsl:apply-templates/>
</graphml>
</xsl:template>

<xsl:template match="graphml:node">
<node>
<xsl:apply-templates select="node()|@*"/>
<data key="labelV">vertex</data>
</node>
</xsl:template>

<xsl:template match="graphml:edge">
<edge id="{@id}" source="{@source}" target="{@target}">
<data key="labelE">
<xsl:value-of select="@label"/>
</data>
Copy link
Member

@pluradj pluradj Jan 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding <xsl:copy-of select="node()"/> here seems to work. Or <xsl:apply-templates select="node()|@*"/> for consistency with the others.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that. My test file had no edge properties.

</edge>
</xsl:template>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appears that this transform creates the labelE child node, but the existing edge properties are not carried over.

</xsl:stylesheet>