Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 293
  • Last Modified:

XSLT Transversing and selection


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="http://www.composite.net/ns/transformation/input/1.0">
    <!-- 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="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:in="http://www.composite.net/ns/transformation/input/1.0">
<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.
  • 2
1 Solution
Geert BormansCommented:
If I just run the XSLT against the XML (I don't see any issues by the way)
I get this

<html xmlns:in="http://www.composite.net/ns/transformation/input/1.0">
      <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?
UCTechsAuthor Commented:
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.
Geert BormansCommented:
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"

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now