[
https://issues.apache.org/jira/browse/TINKERPOP-1608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15963772#comment-15963772
]
ASF GitHub Bot commented on TINKERPOP-1608:
-------------------------------------------
Github user robertdale commented on a diff in the pull request:
https://github.com/apache/tinkerpop/pull/595#discussion_r110806894
--- Diff: gremlin-core/src/main/resources/tp2-to-tp3-graphml.xslt ---
@@ -0,0 +1,59 @@
+<?xml version="1.0" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+-->
+
+
+<!-- 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>
+ <xsl:apply-templates select="node()|@*"/>
--- End diff --
xsltproc is complaining because the apply-templates is not immediately
after a new node when trying to apply selected attributes. From what I can
tell, the only attributes that should be in the <edge> element are already
explicitly defined. It is not necessary to copy attributes (@*) back into the
<edge> element. That appears to be the main difference between TP2 and TP3 -
that the label attribute is now a <data> element with key attribute.
Thus, the attribute selection can be removed.
`<xsl:apply-templates select="node()"/>`
> TP2-to-TP3 GraphML XSLT
> -----------------------
>
> Key: TINKERPOP-1608
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1608
> Project: TinkerPop
> Issue Type: Improvement
> Components: io
> Affects Versions: 3.1.5, 3.2.3
> Reporter: Jason Plurad
>
> There were some changes in the GraphML format between TinkerPop 2 and
> TinkerPop 3. [~joshsh] has [started
> work|https://github.com/apache/tinkerpop/pull/501] on an XSLT to transform
> between the two formats.
> I performed an initial test of the transform using this code within the
> Gremlin Console.
> {noformat}
> import javax.xml.parsers.DocumentBuilderFactory
> import javax.xml.transform.TransformerFactory
> import javax.xml.transform.dom.DOMSource
> import javax.xml.transform.stream.StreamSource
> import javax.xml.transform.stream.StreamResult
> stylesheet = new File('/tmp/tp-graphml-convert.xslt')
> datafile = new File('/tmp/tp2-graphml.xml')
> outfile = new File('/tmp/tp3-graphml.xml')
> tFactory = TransformerFactory.newInstance()
> stylesource = new StreamSource(stylesheet)
> transformer = tFactory.newTransformer(stylesource)
> source = new StreamSource(datafile)
> result = new StreamResult(new FileWriter(outfile))
> transformer.transform(source, result)
> {noformat}
> Example TinkerPop 2 GraphML:
> https://github.com/tinkerpop/gremlin/blob/master/data/graph-example-1.xml
> Example TinkerPop 3 GraphML:
> https://github.com/apache/tinkerpop/blob/3.1.5/data/tinkerpop-classic.xml
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)