我在这里有一些DITA内容。
dita地图如下所示:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN"
"../dtd/technicalContent/dtd/map.dtd">
<map id="e7de5b">
<title/>
<topicmeta>
<othermeta name="title" content="File Loader Guide for SAP HANA"/>
<othermeta name="status" content="Authoring:closed"/>
</topicmeta>
<topicref href="9df1475208c.xml"/>
<mapref href="ec152470.ditamap"/>
</map>
在这个文件夹中,我知道这是主地图,因为它引用了唯一的其他DITA地图(<mapref href="ec152470.ditamap"/>
)。基本上,文件夹的主地图是同一文件夹中没有任何其他地图引用的地图(可以有任意数量的地图)。
我有一个包含所有地图列表的文件,如下所示:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<maps>
<map path="Path\ToTheMap" name="e7de5b.ditamap" />
<map path="Path\ToTheMap" name="ec152470.ditamap" />
</maps>
检查地图是否是文件夹中的主地图的最佳方式是什么?即检查它是否被同一文件夹中的任何其他地图引用?
到目前为止,我已经:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" exclude-result-prefixes="fo fn xs">
<xsl:output method="xml" encoding="utf-8" standalone="yes"/>
<xsl:template match="/">
<docMaps>
<xsl:apply-templates/>
</docMaps>
</xsl:template>
<xsl:template match="maps">
<xsl:for-each-group select="map" group-by="@path">
<xsl:choose>
<xsl:when test="count(current-group()) = 1">
<mapdoc path="{current-grouping-key()}" name="{@name}"/>
</xsl:when>
<xsl:otherwise>
<!-- check -->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>
如果文件夹中只有一张地图,那就太简单了。但在另一种情况下...我尝试了 - 每个循环,但我无法弄明白。
任何帮助都非常感谢!
答案 0 :(得分:0)
文件夹的主地图是同一文件夹中任何其他地图未引用的地图(可以有任意数量的地图)。
听起来像是
select="maps/map[not(doc(@path)/map/mapref/@href = $name)]/@name"