У меня есть узлы уровня 1 в документе, в котором я ищу с атрибутом (@nodeID) и на основе идентификатора узла, я ищу другие узлы, имеющие дочерний атрибут (@nodeID). Существует несколько родительских узлов с атрибутом (@nodeID) и, следовательно, при повторном цикле узлы повторяются. Есть ли решение для этого?
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:kernel="http://www.mondeca.com/system/kernel#" xmlns:itm="http://www.mondeca.com/system/publishing#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:bo="http://www.mondeca.com/system/basicontology#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ap="http://cv.ap.org/ns#" xmlns:t3="http://www.mondeca.com/system/t3#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:dbpedia-owl="http://dbpedia.org/ontology/" xmlns:org="http://www.w3.org/TR/vocab-org/" exclude-result-prefixes="xs" version="2.0"> <xsl:template match="rdf:RDF"> <rdf:RDF xmlns:kernel="http://www.mondeca.com/system/kernel#" xmlns:itm="http://www.mondeca.com/system/publishing#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:bo="http://www.mondeca.com/system/basicontology#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <xsl:apply-templates/> </rdf:RDF> </xsl:template> <xsl:template match="rdf:Description[@rdf:nodeID]"> <xsl:call-template name="addCandidateStatus"> <xsl:with-param name="currentNode" select="node()"/> </xsl:call-template> <xsl:variable name="match" select="@rdf:nodeID"/> <xsl:for-each select="../rdf:Description[rdf:type/@rdf:resource]"> <xsl:if test="*/@rdf:nodeID=$match"> <xsl:for-each select="child::*[@rdf:nodeID]"> <xsl:if test="@rdf:nodeID!=$match"> <xsl:if test="../rdf:Description/@rdf:nodeID!=@rdf:nodeID"> <xsl:message terminate="no"> This element is not present </xsl:message> </xsl:if> </xsl:if> </xsl:for-each> <xsl:choose> <xsl:when test="current()[rdf:type/@rdf:resource='http://cv.ap.org/ns#EventAssociation' or rdf:type/@rdf:resource='http://cv.ap.org/ns#OrganizationAssociation' or rdf:type/@rdf:resource='http://cv.ap.org/ns#Membership']"> <xsl:call-template name="addGeneratedBy"> <xsl:with-param name="currentNode" select="current()"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:copy-of select="current()"/> </xsl:otherwise> </xsl:choose> </xsl:if> </xsl:for-each> </xsl:template> <xsl:template name="addCandidateStatus"> <xsl:param name="currentNode"/> <xsl:element name="rdf:Description"> <xsl:attribute name="rdf:nodeID" select="@rdf:nodeID"/> <xsl:copy-of select="node()"/> <bo:candidate_status rdf:resource="http://www.mondeca.com/system/basicontology#Candidate"/> </xsl:element> </xsl:template> <xsl:template name="addGeneratedBy"> <xsl:param name="currentNode"/> <xsl:element name="rdf:Description"> <xsl:attribute name="rdf:about" select="@rdf:about"/> <xsl:copy-of select="node()"/> <xsl:element name="wasGeneratedBy" namespace="http://cv.ap.org/ns#">import</xsl:element> <!-- <xsl:element name="generatedAtTime" namespace="http://cv.ap.org/ns#"><xsl:value-of select="current-dateTime()"/></xsl:element>--> </xsl:element> </xsl:template> <xsl:template match="node()|@*"> <xsl:apply-templates select="@*|node()"/> </xsl:template> </xsl:stylesheet> <!--<xsl:template match=" rdf:Description[rdf:type/@rdf:resource='http://cv.ap.org/ns#Politician' and @rdf:nodeID]"> <xsl:copy-of select="current()"/> <xsl:variable name="match" select="@rdf:nodeID"/> <xsl:for-each select="../rdf:Description[*/@*=$match]"> <xsl:copy-of select="current()"/> </xsl:for-each> </xsl:template>--> <!-- <xsl:template match="node()|@*"> <xsl:apply-templates select="@*|node()"/> </xsl:template> --> <!-- <xsl:element name="time"> </xsl:element> --> <!-- <xsl:template match="rdf:Description"> <xsl:if test="@rdf:nodeID "> <xsl:if test="rdf:type[@rdf:resource != 'http://cv.ap.org/ns#OrganizationAssociation']"> <xsl:copy-of select="current()"/> </xsl:if> </xsl:if> </xsl:template> --> <!-- <xsl:template match="rdf:Description[rdf:type/@rdf:resource !='http://cv.ap.org/ns#Membership' and @rdf:nodeID]"> <xsl:copy-of select="current()"/> </xsl:template> <xsl:template match="node()|@*"> <xsl:apply-templates select="@*|node()"/> </xsl:template> --> <!-- <xsl:template match="rdf:Description[rdf:type/@rdf:resource ='http://cv.ap.org/ns#Membership' and @rdf:about]"> <xsl:copy-of select="current()"/> </xsl:template> <xsl:template match="node()|@*"> <xsl:apply-templates select="@*|node()"/> </xsl:template> </xsl:stylesheet> -->