XSLT matching PAGEID to an element ID -


how match 2 separate numbers in xml document? there multiple <pgindexelementinfo> elements in xml document, each representing different navigation element, each unique <id>. later in document <pageid> specifies number matches <id> used above. how go matching <pageid> <id> specified above?

<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:

i added solution below code. xsl:apply-templates present used recreate nested lists lost between html , xml. need match pageid id of <pgindexelementitem> , add css class <ul> part of. hope makes sense.

<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)         , not(contains(substring-after(description, $prefix), '.'))]"/>     <xsl:if test="$childoptions">       <ul>         <xsl:apply-templates select="$childoptions" />       </ul>     </xsl:if>   </li> </xsl:template> 

the xslt way dealing cross references keys.

matching: rule matching every pageid element has been referenced id element.

<xsl:key name="kidbyvalue" match="id" use="."/>  <xsl:template match="pageid[key('kidbyvalue',.)]">      <!-- template content --> </xsl:template> 

selecting: expression selecting every pageid element specific value.

<xsl:key name="kpageidbyvalue" match="pageid" use="."/>  <xsl:template match="id">      <xsl:apply-templates select="key('kpageidbyvalue',.)"/> </xsl:template> 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -