0
XML文書内の2つの別個の番号はどのように一致しますか?私の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>
EDIT:
私は自分のコードに以下の溶液を添加。存在するxsl:apply-templates
は、HTMLとXMLの間で失われた入れ子リストを再作成するために使用されます。私が今必要とするのは、PageIDと<PgIndexElementItem>
のIDをマッチさせて、それがCSSの一部である<ul>
にCSSクラスを追加することです。私はそれが理にかなったことを願う
<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