c# - IF statement in xslt for matching two id in BlogCategories -


i want match blogcategory parentid parent id.. here code:

 <?xml version="1.0" encoding="utf-8"?>             <blogcategories>      <blogcategory id="1" parentid="0" name="travel" active="1" seo_keywords="travel blogs" seo_description="travel blogs" parentname=""/>      <blogcategory id="13" parentid="1" name="destinations" active="1" seo_keywords="destinations" seo_description="destinations" parentname="travel"/>      <parent id="1" parentname="travel"/>      <parent id="2" parentname="healthcare"/>         </blogcategories> 

this .xslt page:

<xsl:for-each select="parent">      <div class="grid-row3">      <ul>        <a href="">          <xsl:value-of select="@parentname"></xsl:value-of>        </a>        <xsl:for-each select="/blogcategories/blogcategory">          <xsl:if test="@parentid=@id">            <li>              <a href="">                <xsl:value-of select="@name"></xsl:value-of>              </a>            </li>          </xsl:if>        </xsl:for-each>      </ul>      </div>         </xsl:for-each> 

the problem parentid of block category( <blogcategory id="1" parentid="0" name="travel" active="1" seo_keywords="travel blogs" seo_description="travel blogs" parentname=""/>) not match id of parent( <parent id="1" parentname="travel"/>)

i.e. if manually <xsl:if test="@parentid=1"> work..but if same things ..then problem here: <xsl:if test="@parentid=@id">

how match @parentid=@id

try replacing:

<xsl:for-each select="/blogcategories/blogcategory"> 

with:

<xsl:for-each select="/blogcategories/blogcategory[@parentid = current()/@id]"> 

then won't need xsl:if instruction @ all.

the way trying work if had stored parent/@idvalue in variable before calling xsl:for-each - because xsl:for-each instruction changes context.

another option (preferable, imho) use key resolve cross-references.


note xml case-sensitive: cannot use @id select attribute named id.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -