我再次提出这个问题的抱歉。我知道这已经好几次在这里得到了解答,但似乎我还没有得到它。
我的XML(基本上是Open Office绘制的XML输出,这里简化了)
<?xml version="1.0" encoding="UTF-8"?>
<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.graphics">
<office:body>
<office:drawing>
<draw:page draw:name="page1" draw:master-page-name="Standard">
<draw:connector draw:type="curve" draw:start-shape="id1" draw:end-shape="id2" />
<draw:connector draw:type="curve" draw:start-shape="id2" draw:end-shape="id3" />
<draw:connector draw:type="curve" draw:start-shape="id3" draw:end-shape="id4" />
<draw:connector draw:type="curve" draw:start-shape="id1" draw:end-shape="id4" />
<draw:connector draw:type="curve" draw:start-shape="id1" draw:end-shape="id3" />
<draw:custom-shape >
<text:p >
<text:span >AAAA,</text:span>
</text:p>
</draw:custom-shape>
<draw:custom-shape draw:id="id1" >
<text:p >
<text:span >BBBBB</text:span>
</text:p>
</draw:custom-shape>
<draw:custom-shape draw:id="id2" >
<text:p >
<text:span >CCCCC.</text:span>
</text:p>
</draw:custom-shape>
<draw:custom-shape draw:id="id3" >
<text:p >
<text:span >DDDDDDDDDD</text:span>
</text:p>
</draw:custom-shape>
<draw:custom-shape draw:id="id4" >
<text:p >
<text:span >EEEEEEEEEE</text:span>
</text:p>
</draw:custom-shape>
</draw:page>
</office:drawing>
</office:body>
</office:document>
现在我尝试使用
将其转换为yEd的graphml<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
xmlns:math="http://www.w3.org/1998/Math/MathML"
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
xmlns:ooo="http://openoffice.org/2004/office"
xmlns:ooow="http://openoffice.org/2004/writer"
xmlns:oooc="http://openoffice.org/2004/calc"
xmlns:dom="http://www.w3.org/2001/xml-events"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
xmlns:rpt="http://openoffice.org/2005/report"
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:grddl="http://www.w3.org/2003/g/data-view#"
xmlns:officeooo="http://openoffice.org/2009/office"
xmlns:tableooo="http://openoffice.org/2009/table"
xmlns:drawooo="http://openoffice.org/2010/draw"
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0"
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
xmlns:css3t="http://www.w3.org/TR/css3-text/">
<xsl:template match="/"> <!-- graphml xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd" xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://www.yworks.com/xml/yfiles-common/1.0/java" xmlns:sys="http://www.yworks.com/xml/yfiles-common/markup/primitives/2.0" xmlns:x="http://www.yworks.com/xml/yfiles-common/markup/2.0" xmlns:y="http://www.yworks.com/xml/graphml" xmlns:yed="http://www.yworks.com/xml/yed/3" -->
<graphml xmlns:x="http://www.yworks.com/xml/yfiles-common/markup/2.0" xmlns:yed="http://www.yworks.com/xml/yed/3" xmlns:java="http://www.yworks.com/xml/yfiles-common/1.0/java" xmlns:h="http://graphml.graphdrawing.org/xmlns" xmlns:sys="http://www.yworks.com/xml/yfiles-common/markup/primitives/2.0" 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" exclude-result-prefixes="h">
<key for="node" id="d6" yfiles.type="nodegraphics"/>
<key for="port" id="d2" yfiles.type="portuserdata"/>
<key attr.name="N_In" attr.type="int" for="node" id="d3">
<default>0</default>
</key>
<graph id="G" edgedefault="directed">
====================================
<xsl:for-each select="//draw:custom-shape|//draw:frame">
+++++++++++++++++++++++++++++++++++++++++
<xsl:element name="node">
<xsl:attribute name="id">
<xsl:value-of select="@draw:id"/>
</xsl:attribute>
<xsl:variable name="my_node" select="@draw:id"/><!-- xsl:value-of select="$my_node"/ -->
<xsl:element name="data">
<xsl:attribute name="key">d4</xsl:attribute>
<xsl:value-of select="count(//draw:connector[@draw:start-shape=$my_node])"/>
</xsl:element>
<xsl:element name="data">
<xsl:attribute name="key">d3</xsl:attribute>
<xsl:value-of select="count(//draw:connector[@draw:end-shape=$my_node])"/>
</xsl:element>
<xsl:element name="data">
<xsl:attribute name="key">d5</xsl:attribute>
<xsl:value-of select="count(//draw:connector[@draw:start-shape=$my_node])-count(//draw:connector[@draw:end-shape=$my_node])"/>
</xsl:element>
<xsl:apply-templates select="h:In_Counts"/>
<xsl:call-template name="h:In_Counts" />
</xsl:element>
</xsl:for-each>
</graph>
</graphml>
</xsl:template>
<xsl:template match="h:In_Counts" >
in in_counts ------------------------------------------
</xsl:template>
</xsl:stylesheet>
我的问题: 我仍然没有得到匹配的(子)模板。 我的想法在哪里结?
提前感谢!
答案 0 :(得分:1)
那里有几个问题:
<xsl:apply-templates select="h:In_Counts"/>
不匹配,因为XML文件中没有<In_Counts>
个元素。<xsl:call-template name="h:In_Counts"/>
失败,因为没有<xsl:template name="h:In_Counts">
(请注意name
属性)。