2017-05-23 7 views
0

XSLT를 사용하여 graphml을 HTML로 변환하는 데 문제가 있습니다. 내가하려는 변환은 매우 간단하지만이 시점에서 내가 잘못하고있는 것을 이해할 수는 없습니다. 이것은 graphml 변환하는 데 사용됩니다 내 XSL입니다XSLT를 사용하여 적절한 태그 이름을 사용하여 그래프를 변형하는 올바른 방법은 무엇입니까?

<?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: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> 

나는 여러 가지 방법으로이 하나의 작업을 시도했지만 작동하지 않았습니다. 행을 제대로 추가하기 위해 노드 템플리트를 적용하고 적용하지 않는 이유는 무엇입니까?

감사합니다.

답변

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> 
    ...