0
내 접근 방식이 작동하지 않는 이유를 이해하기가 정말 힘듭니다. 태그의 텍스트와 연결된 고유 한 숫자 ID를 할당하려고합니다. 어떤 이유로, 첫 번째 ID가 올바르게 계산되지만 다른 모든 항목은 비어 있습니다 ... xsltproc을 사용하면 문제가됩니다.xslt 번호 매기기 유선 동작
XML 입력
<a>
<b><c>one</c></b>
<b><c>two</c></b>
<b><c>one</c></b>
<b><c>three</c></b>
<b><c>two</c></b>
<b><c>four</c></b>
<b><c>one</c></b>
</a>
예상 XML 출력
<?xml version="1.0"?>
<gg>
<ff id="1">one</ff>
<ff id="2">two</ff>
<ff id="1">one</ff>
<ff id="3">three</ff>
<ff id="2">two</ff>
<ff id="4">four</ff>
<ff id="1">one</ff>
</gg>
실제 잘못된 출력 :
<?xml version="1.0"?>
<gg>
<ff id="1">one</ff>
<ff id="2">two</ff>
<ff id="">one</ff>
<ff id="3">three</ff>
<ff id="">two</ff>
<ff id="4">four</ff>
<ff id="">one</ff>
</gg>
XSLT 스타일 시트 가짜
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" indent="yes"/>
<xsl:key name="groups" match="//b" use="c/text()" />
<xsl:template match="/a">
<gg>
<xsl:apply-templates select="b"/>
</gg>
</xsl:template>
<xsl:template match="b">
<xsl:variable name="ff">
<xsl:call-template name="groupd">
<xsl:with-param name="cc" select="c" />
</xsl:call-template>
</xsl:variable>
<ff id="{$ff}"><xsl:value-of select="c"/></ff>
</xsl:template>
<xsl:template name="groupd">
<xsl:param name="cc" select="."/>
<xsl:number
count="//b[generate-id() = generate-id(key('groups', c/text())[1])]"
format="1" />
</xsl:template>
</xsl:stylesheet>
당신이 가진 요소의 "표"를 재고 그 muenchian grouping에서 상대 위치를 찾은 다음 * node-set *을 사용하여 해당 테이블을 쿼리합니다. 이 방법을 처음으로 접하게됩니다. 도와 줘서 고마워. 이 문제의 대부분이 오늘 막혔습니다. –
'node-set()'함수가 변수를 * 결과 트리 조각 *에서 * 노드 집합 *으로 변환하는 데 사용된다는 것을 제외하면 대부분 정확합니다. 이것은 XSLT 1.0 버젼입니다 : RTF에서 노드의 위치를 얻을 수 없습니다. –