2016-11-02 8 views
-1

私はxmlのような形式でカスタムグラフィックフォーマットを持っています。ノードをtextviewedgeのように並べ替えるのは間違いありません。私のアプローチは、xmlからsvgまでのXSLの変換を使用することです。私はsvg形式に新しいですが、xsl previosulyで少し働いた。そのような仕事が既にgraphml to svgのように解決されたのかどうかはyEdにあるのだろうか。そのような変換を行う便利な方法がいくつかありますか?カスタムグラフィックフォーマットを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> 

私はちょうどrectsにnodeviewsを変換することができ、サンプルxsltを作成しましたが、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> 

答えて

3

あなたのスタイルシートの主な問題は、作成している要素がSVG名前空間にないことです。 、

xmlns="http://www.w3.org/2000/svg" 

他の事はあなたの計算は、負の高さを返すことです:に

xmlns:svg="http://www.w3.org/2000/svg" 

:これを変更し、IOW - あなたは、スタイルシートのデフォルトの名前空間SVG名前空間を作ることによって簡単にそれを修正することができますSVGでは許可されていません。

+0

私はそれを変更しました。要素は現在svg nsになりますが、グラフィックはすでに隠れています。しかし、私はinkscapeのXMLエディタを使って見ることができます。 – Juriy

+0

@ジュリーあなたが何を言おうとしているのか分かりません。 –

+1

@Juriy:この回答は、あなたの2つの主な問題をカバーしています。 [** accepting **](http://meta.stackoverflow.com/q/5234/234215)を検討し、残りの問題については、最初に手作業でSVGを作成して、必要な結果を達成してみてください。 SVGをXSLTでターゲット設定する方が簡単になります。 – kjhughes

関連する問題