-1
我有xml
-like格式的自定義圖形格式。我想要按原樣安排節點textview
和edge
。我的方法是使用從xml
到svg
的XSL
轉換。我是svg格式的新手,但在xsl
之前工作過一點。我想知道yEd
這個任務是否已經解決了graphml to svg
功能。有沒有一些方便的方法來進行這樣的轉換?如何通過XSLT將自定義圖形格式轉換爲SVG圖形視圖?
<?xml version="1.0" encoding="windows-1251"?>
<project version="1.2">
<calc allowworktime="false" cutoff="0"/>
<sfc>
<graphview>
<nodeview idref="1">
<properties>
<color value="#FF000000" name="outline.color"/>
<rectangle left="165" top="85" right="195" bottom="115" name="bounds"/>
<color value="#FFFFFFFF" name="fill.color"/>
</properties>
</nodeview>
<edgeview idref="1">
<properties>
<color value="#FF000000" name="outline.color"/>
</properties>
</edgeview>
<textview>
<properties>
<color value="#00000000" name="outline.color"/>
<color value="#FF000000" name="label.font.color"/>
<integer value="8" name="label.font.size"/>
<rectangle left="176" top="63" right="194" bottom="78" name="bounds"/>
<string value="Tahoma" name="label.font.family"/>
<color value="#00000000" name="fill.color"/>
<integer value="0" name="label.font.style"/>
<string value="Ë1" name="label.text"/>
</properties>
</textview>
</graphview>
</sfc>
</project>
我剛剛創建的樣本xslt
,可以改變nodeviews到rects,但在Inkscape中打開時,SVG不以某種方式呈現。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:local="local"
exclude-result-prefixes="xs"
version="2.0"
xmlns:svg="http://www.w3.org/2000/svg">
<xsl:output indent="yes"/>
<xsl:template match="/">
<svg>
<xsl:apply-templates select="@* | node()"/>
</svg>
</xsl:template>
<xsl:template match="//graphview/nodeview">
<xsl:variable name="nodeleft" select="properties/rectangle/@left"/>
<xsl:variable name="noderight" select="properties/rectangle/@right"/>
<xsl:variable name="nodetop" select="properties/rectangle/@top"/>
<xsl:variable name="nodebottom" select="properties/rectangle/@bottom"/>
<!-- adding svg group item -->
<g>
<xsl:element name="rect">
<xsl:attribute name="x"><xsl:value-of select="$nodeleft"/></xsl:attribute>
<xsl:attribute name="width"><xsl:value-of select="($noderight - $nodeleft)"/></xsl:attribute>
<xsl:attribute name="height"><xsl:value-of select="($nodetop - $nodebottom)"/></xsl:attribute>
<xsl:attribute name="y"><xsl:value-of select="($nodetop)"/></xsl:attribute>
</xsl:element>
</g>
</xsl:template>
</xsl:stylesheet>
我已經改變了它,元素現在在svg ns中,但圖形已經隱藏了。但我可以通過inkscape中的xml編輯器查看它。 – Juriy
@Juriy我不確定你想說什麼。 –
@Juriy:這個答案涵蓋了你的兩個主要問題。考慮[**接受它](http://meta.stackoverflow.com/q/5234/234215),然後對於其他問題,請嘗試首先手動創建SVG,以實現您想要的結果。然後,通過XSLT定位SVG將變得更加容易。 – kjhughes