Link to home
Start Free TrialLog in
Avatar of UCTechs
UCTechs

asked on

XSLT Transversing and selection

Hi,

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>
                </Page>
                <Page  MenuTitle="Nordic Track" UrlTitle="Nordic-Track" Description=""  FolderPath="/Home/Treadmills-Reviews/Nordic-Track" Depth="3"/>
			</Page>
			<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"/>
        </Page>
    </in:result>
</in:inputs>

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">
<html>
  <head>
    <title>Test</title>

  </head>
  <body>
    <span>
      <xsl:apply-templates select="//Page[@iscurrent = 'true']"/>
    </span>
  </body>
</html>
</xsl:template>

<xsl:template match="Page">

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

</xsl:template>

</xsl:stylesheet>

Open in new window


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

Any thoughts or solutions?

Thanks in advance.
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

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">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Test</title>
   </head>
   <body><span>Treadmills Reviews</span></body>
</html>

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?
Avatar of UCTechs
UCTechs

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial