IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

help getting title of second level category links Options · View
azriley
Posted: Tuesday, April 26, 2016 7:27:12 PM
Rank: Newbie

Joined: 4/26/2016
Posts: 2
Hi,

Probably a simple one but how do you get just the top level (2nd page node) categories in the below XML so that if you're in Online or PersonalizedEducation you get WHY? as the title? and if you're in Grad or Undergrad you get Programs as the title of the parent?

Thanks,
Aaron


Code:
<site>
<page id="2604" linktarget="" map="1" nav="1" alias="Home" title="Home">
    <page id="2605" linktarget="" alias="Why" title="WHY?" map="1" nav="1">
        <page id="2606" linktarget="" alias="AboutOurSchool" title="About Our School" map="1" nav="1">
            <page id="2609" linktarget="" alias="PersonalizedEducation" title="Personalized Education" map="1" nav="1" />
            <page id="2610" linktarget="" alias="Online" title="Online" map="1" nav="1" />
        </page>
        <page id="2611" linktarget="" alias="BecomingaTeacher" title="Becoming a Teacher" map="1" nav="1"/>
        <page id="2612" linktarget="" alias="Partnerships" title="Partnerships" map="1" nav="1" />
        <page id="2613" linktarget="" alias="AdvancedPractice" title="Advanced Practice" map="1" nav="1" />
    </page>

    <page id="2607" linktarget="" alias="PROGRAMS" title="PROGRAMS" map="1" nav="1">
        <page id="2645" linktarget="" alias="Undergrad" title="Undergrad" map="1" nav="1"/>
        <page id="2646" linktarget="" alias="Grad" title="Grad" map="1" nav="1" />

    </page>
    <page id="2608" linktarget="" alias="TRANSFER" title="TRANSFER" map="1" nav="1">
        <page id="2647" linktarget="" alias="Transfer" title="Transfer" map="1" nav="1"/>
    </page>
    <page id="2614" linktarget="" alias="EDUCATION" title="EDUCATION" map="1" nav="1">
        <page id="2648" linktarget="" alias="Education" title="Education" map="1" nav="1"/>
    </page>
    <page id="2615" linktarget="" alias="SOCIALSCIENCES" title="SOCIAL SCIENCES" map="1" nav="1">
        <page id="2649" linktarget="" alias="Social Sciences" title="Social Sciences" map="1" nav="1"/>
    </page>
    <page id="2616" linktarget="" alias="PHD" title="PHD" map="1" nav="1">
        <page id="2650" linktarget="" alias="PhD" title="PhD" map="1" nav="1"/>
    </page>
    <page id="2617" linktarget="" alias="ALUMNI" title="ALUMNI" map="1" nav="1">
        <page id="2651" linktarget="" alias="Alumni" title="Alumni" map="1" nav="1"/>
    </page>
</page>
</site>




vlad
Posted: Wednesday, April 27, 2016 9:04:15 AM
Rank: Advanced Member

Joined: 12/13/2005
Posts: 2,856
Location: Mauritius
ancestor::page[ last() - 1 ]
azriley
Posted: Wednesday, April 27, 2016 2:42:45 PM
Rank: Newbie

Joined: 4/26/2016
Posts: 2
Thanks for the reply!

That was enough to get me moving in the right direction. Used the below:

Code:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" indent="yes" />
    <xsl:param name="page_id">0</xsl:param>
    <xsl:variable name="parent" select="site/page/page[@id=$page_id or .//page/@id=$page_id]" />
    <xsl:template match="/">
<!-- example override page id for testing -->
        <xsl:variable name="page_id" select="2605" />

        <xsl:if test="$parent">
            <h3>
                <a href="default.aspx?id={$parent/@id}">
                    <xsl:value-of select="$parent/@title" disable-output-escaping="yes" />
                </a>
            </h3>

        </xsl:if>

  </xsl:template>
</xsl:stylesheet>

Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.