我很缺乏经验,所以我想要一些帮助。
我以XML格式导出Filemaker数据库,这是结果
<?xml version="1.0" encoding="UTF-8"?>
<!-- Questa grammatica non è più in uso - usare FMPXMLRESULT al suo posto -->
<FMPDSORESULT>
<ROW MODID="5" RECORDID="2">
<FASCICOLO>Adams John</FASCICOLO>
<TITOLO_DOC>John Adams to Mr X</TITOLO_DOC>
<LUOGO>New York</LUOGO>
<GG>27</GG>
<MM>04</MM>
<AA>1969</AA>
<CONTENUTO>Greetings</CONTENUTO>
<TIPOLOGIA>letter</TIPOLOGIA>
<NUM_CARTE>1</NUM_CARTE>
<INTEGR_DESC/>
</ROW>
<ROW MODID="6" RECORDID="6">
<FASCICOLO>Adams John</FASCICOLO>
<TITOLO_DOC>John Adams to Mr X</TITOLO_DOC>
<LUOGO>s.l.</LUOGO>
<GG>03</GG>
<MM>07</MM>
<AA>1996</AA>
<CONTENUTO>Greetings</CONTENUTO>
<TIPOLOGIA>letter</TIPOLOGIA>
<NUM_CARTE>3</NUM_CARTE>
<INTEGR_DESC>Presente la busta originale.</INTEGR_DESC>
</ROW>
等。 (我没有全部复制过)
我用这个XSL文件来转换它
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" encoding="iso-8859-1"/>
<xsl:template match="/">
<xsl:element name="dsc">
<xsl:for-each select="//ROW">
<xsl:element name="c">
<xsl:attribute name="level">file</xsl:attribute>
<xsl:attribute name="id">.</xsl:attribute>
<xsl:element name="did">
<xsl:element name="unittitle">
<xsl:attribute name="encodinganalog">ISAD 1 - 2 title</xsl:attribute>
<xsl:value-of select="./FASCICOLO/text()"/>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
我得到了这个XML文件
<?xml version="1.0" encoding="ISO-8859-1"?>
<dsc>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">Adams John</unittitle>
</did>
</c>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">Adams John</unittitle>
</did>
</c>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">Doe Jane</unittitle>
</did>
</c>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">Doe Jane</unittitle>
</did>
</c>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">Doe Jane</unittitle>
</did>
</c>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">Doe Jane</unittitle>
</did>
</c>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">Green Charles</unittitle>
</did>
</c>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">Green Charles</unittitle>
</did>
</c>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">Green Charles</unittitle>
</did>
</c>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">Jones Charles</unittitle>
</did>
</c>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">White Walter</unittitle>
</did>
</c>
我需要得到相同的信息,但这些名字只重复一次,这样:
<?xml version="1.0" encoding="ISO-8859-1"?>
<dsc>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">Adams John</unittitle>
</did>
</c>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">Doe Jane</unittitle>
</did>
</c>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">Green Charles</unittitle>
</did>
</c>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">Jones Charles</unittitle>
</did>
</c>
<c level="file" id=".">
<did>
<unittitle encodinganalog="ISAD 1 - 2 title">White Walter</unittitle>
</did>
</c>
这是一个例子,真正的文件会更大,可能有很多重复,所以我不想手动删除它们。可能吗?非常感谢你
答案 0 :(得分:1)
首先,如果从Filemaker导出,则可以消除源中结果的重复项。
其次,如果您在导出期间应用XSLT,则可以使用xalan:distinct()
扩展功能来消除转换期间的重复项。如果您使用的是版本11或更高版本,则还可以使用EXSLT set:distinct()
功能。