2017-05-23 1 views
0

私はgraphmlをXSLTを使ってHTMLに変換するのに問題があります。 私がしようとしている変換はかなりシンプルですが、現時点で何が間違っているのか分かりません。XSLTを使用して適切なタグ名を使用してグラフを変換する正しい方法は何ですか?

これは私が変換したい私のgraphmlです:

<?xml version="1.0" encoding="UTF-8"?> 
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"> 
    <key for="node" id="d0" yfiles.type="nodegraphics"/> 
    <key for="edge" id="d1" yfiles.type="edgegraphics"/> 

    <graph id="dependencies" edgedefault="directed"> 

    <node id="2086673744"> 
     <data key="d0"> 
     <y:ShapeNode> 
      <y:NodeLabel>com.quadreal.mulesoft.services:qr-identitymgmt-services:mule:3.0.0-SNAPSHOT</y:NodeLabel> 
     </y:ShapeNode> 
     </data> 
    </node> 

    <node id="1296670053"> 
     <data key="d0"> 
     <y:ShapeNode> 
      <y:NodeLabel>com.quadreal.mulesoft.context:quadreal-runtime-context:jar:1.0.0-SNAPSHOT:compile</y:NodeLabel> 
     </y:ShapeNode> 
     </data> 
    </node> 

    <edge source="2086673744" target="1296670053"> 
     <data key="d1"> 
     <y:PolyLineEdge> 
      <y:EdgeLabel>compile</y:EdgeLabel> 
     </y:PolyLineEdge> 
     </data> 
    </edge> 

    <node id="826245889"> 
     <data key="d0"> 
     <y:ShapeNode> 
      <y:NodeLabel>com.quadreal.mulesoft.library:qr-common-error-library:jar:2.0.0-SNAPSHOT:compile</y:NodeLabel> 
     </y:ShapeNode> 
     </data> 
    </node> 

    <node id="1556730832"> 
     <data key="d0"> 
     <y:ShapeNode> 
      <y:NodeLabel>com.quadreal.mulesoft.notification:quadreal-utility-common-domains:jar:3.0.0-SNAPSHOT:compile</y:NodeLabel> 
     </y:ShapeNode> 
     </data> 
    </node> 

    <edge source="826245889" target="1556730832"> 
     <data key="d1"> 
     <y:PolyLineEdge> 
      <y:EdgeLabel>compile</y:EdgeLabel> 
     </y:PolyLineEdge> 
     </data> 
    </edge> 

    <edge source="2086673744" target="826245889"> 
     <data key="d1"> 
     <y:PolyLineEdge> 
      <y:EdgeLabel>compile</y:EdgeLabel> 
     </y:PolyLineEdge> 
     </data> 
    </edge> 

    </graph> 
</graphml> 

これはgraphmlを変換するために使用される私のXSLです:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output method="html" indent="yes"/> 

    <xsl:template match="/"> 
     <html> 
     <body> 
      <h1>Dependencies:</h1> 
      <table border="1" width="300"> 
      <tr><th>Package Name</th><th>Dependencies</th></tr> 
      <xsl:apply-templates select="/graphml/graph/*"/> 
      </table> 
     </body> 
     </html> 
    </xsl:template> 

    <xsl:template match="node"> 
     <tr><td><xsl:value-of select="data/ShapeNode/NodeLabel"/></td><td>TBD</td></tr> 
    </xsl:template> 

</xsl:stylesheet> 

そして、これは私が取得しています出力されます:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><META http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div> 
<h1>Dependencies:</h1> 
<table border="1" width="300"><tr> 
<th>Package Name</th> 
<th>Dependencies</th> 
</tr></table> 
</div> 
</body></html> 

私はこの1つを動作させるためにさまざまな方法で試しましたが、動作しませんでした。 ノードテンプレートを照合して適用すると、行が正しく追加されないのはなぜですか?

ありがとうございました!

答えて

0

nodeが名前空間にあるので、それが一致していませんxmlns="http://graphml.graphdrawing.org/xmlns"

(空でない接頭辞)あなたのスタイルシート内の同じ名前空間を宣言し、XPath式で使用

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:g="http://graphml.graphdrawing.org/xmlns" 
    xmlns:y="http://www.yworks.com/xml/graphml"> 

    ... 
    <xsl:apply-templates select="/g:graphml/g:graph/*"/> 
    ... 
    <xsl:template match="g:node"> 
     <tr><td><xsl:value-of select="g:data/y:ShapeNode/y:NodeLabel"/></td><td>TBD</td></tr> 
    </xsl:template> 
    ... 
関連する問題