XSLT Transversing and selection

Posted on 2011-10-07
Last Modified: 2013-11-18

I am pretty new to xslt and am have issues with particular part of  a project.

I have this xml file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="headername.xsl"?>

<in:inputs xmlns:in="">
    <!-- Function Call Result (0 ms), XPath /in:inputs/in:result[@name='SitemapXml']/Page -->
    <in:result name="SitemapXml">
        <Page  MenuTitle="Frontpage" UrlTitle="Home"  FolderPath="/Home" Depth="1"  xmlns="">
            <Page Title="Sitemap" UrlTitle="Sitemap" Description=""  FolderPath="/Home/Sitemap" Depth="2" />
            <Page  MenuTitle="Treadmills Reviews" UrlTitle="Treadmills-Reviews" Description=""  FolderPath="/Home/Treadmills-Reviews" Depth="2" isopen="true" iscurrent="true"  >
                <Page MenuTitle="Sole Fitness" UrlTitle="Sole-Fitness" Description=""  FolderPath="/Home/Treadmills-Reviews/Sole-Fitness" Depth="3">
                    <Page  MenuTitle="F-Series" UrlTitle="F-Series" Description=""  FolderPath="/Home/Treadmills-Reviews/Sole-Fitness/F-Series" Depth="4">
                        <Page  MenuTitle="F63" UrlTitle="F63" Description=""  FolderPath="/Home/Treadmills-Reviews/Sole-Fitness/F-Series/F63" Depth="5" />
                <Page  MenuTitle="Nordic Track" UrlTitle="Nordic-Track" Description=""  FolderPath="/Home/Treadmills-Reviews/Nordic-Track" Depth="3"/>
			<Page  MenuTitle="Our Top Picks" UrlTitle="Our-Top-Picks" Description=""  FolderPath="/Home/Our-Top-Picks" Depth="2"/>
			<Page MenuTitle="Forums" UrlTitle="Forums" Description=""  FolderPath="/Home/Forums" Depth="2"/>

Open in new window

I am trying to transverse the nodes with xslt and then print out the value of the "MenuTitle" of the node that "iscurrent='true'". There could be any number of levels of "Page" nodes as well as the "iscurrent" attribute will only be in which ever page is currently open.

My xslt file is as follows:
<xsl:stylesheet xmlns:xsl="" version="1.0" xmlns:in="">
<xsl:output method="html" indent="yes"/>

<xsl:template match="in:result">

      <xsl:apply-templates select="//Page[@iscurrent = 'true']"/>

<xsl:template match="Page">

  <xsl:value-of select="@MenuTitle"/>



Open in new window

However when I run the xml file I just get a blank screen.

Any thoughts or solutions?

Thanks in advance.
Question by:UCTechs
    LVL 60

    Expert Comment

    by:Geert Bormans
    If I just run the XSLT against the XML (I don't see any issues by the way)
    I get this

    <html xmlns:in="">
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       <body><span>Treadmills Reviews</span></body>

    That is exactly what you would expect I guess

    So your problem must be outside the XSLT.
    Can you tell me how you run this actually?

    Author Comment

    I just opened it in a web browser to test, but after writing this post, I tried to use it in the actual application that it is for and it works,  but just not alone in the browser for some reason.  So I guess at this point I am more curious why it works in my application and not alone.  I appreciate the time taken to respond.
    LVL 60

    Accepted Solution

    maybe you have a browser that does not support XSLT, some don't
    For me the combination XML and XSLT works in Internet Explorer, FireFox and Opera, all on windows
    Make sure the XSLT is found by the xml-stylesheet PI, so the XSLT is alongside the XML having a name "headername.xsl"

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
    I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now