XML 문서에서 두 개의 개별 숫자를 어떻게 일치시킬 수 있습니까? 내 XML 문서에는 <PgIndexElementInfo>
요소가 여러 개 있습니다. 각 요소는 각각 고유 한 <ID>
이있는 다른 탐색 요소를 나타냅니다. 문서의 뒷부분에있는 <PageID>
은 위에 사용 된 <ID>
과 일치하는 번호를 지정합니다. 위에 명시된 <ID>
에 <PageID>
을 어떻게 대응시킬 수 있습니까?요소 ID에 대한 PAGEID를 일치하는 XSLT
<Element>
<Content>
<PgIndexElementInfo>
<ElementData>
<Items>
<PgIndexElementItem>
<ID>1455917</ID>
</PgIndexElementItem>
</Items>
</ElementData>
</PgIndexElementInfo>
</Content>
</Element>
<Element>
<Content>
<CustomElementInfo>
<PageID>1455917</PageID>
</CustomElementInfo>
</Content>
</Element>
편집 :
나는 내 코드에 아래의 솔루션을 추가했습니다. 존재하는 xsl:apply-templates
은 HTML과 XML 사이에서 손실되는 중첩 목록을 다시 만드는 데 사용됩니다. 지금해야 할 일은 PageID를 <PgIndexElementItem>
의 ID와 일치시키고 CSS 클래스를 <ul>
에 추가하는 것입니다. 나는 그것이 의미가 있기를 바랍니다.
<xsl:key name="kIDByValue" match="ID" use="."/>
<xsl:template match="PageID[key('kIDByValue',.)]">
<xsl:apply-templates select="//PgIndexElementItem[not(contains(Description, '.'))]" />
</xsl:template>
<xsl:template match="PgIndexElementItem">
<li>
<a href="{ResolvedURL/Absolute}"><xsl:value-of select="Title"/></a>
<xsl:variable name="prefix" select="concat(Description, '.')"/>
<xsl:variable name="childOptions"
select="../PgIndexElementItem[starts-with(Description, $prefix)
and not(contains(substring-after(Description, $prefix), '.'))]"/>
<xsl:if test="$childOptions">
<ul>
<xsl:apply-templates select="$childOptions" />
</ul>
</xsl:if>
</li>
</xsl:template>
정답은 –
입니다.'
jrottier