?
Solved

referencing sites in xsl using xml

Posted on 2003-02-19
8
Medium Priority
?
250 Views
Last Modified: 2010-04-17
hi,
i am a beginner in xml. i hav two files one xml and other xsl as given below.
my aim is to get particular sites by clicking the reference.
how can i do that,
first time i got the links displayed, but now nothing is coming.
can u modify this programs or give me guidelines.
thanks
jasmine

websites.xml

<?xml version="1.0"?>
<?xml-stylesheet href="WebSites.xsl"
                 type="text/xsl"?>
<WebSites>
     <Tourism>
           <Name>Expedia</Name>
           <Name>kcts</Name>    
           <Name>indtravel</Name>
           <Name>travelanza</Name>  
     </Tourism>
     <Automotive>
           <Name>carsdirect</Name>
           <Name>carsmart</Name>
           <Name>motortrend</Name>
           <Name>autotrader</Name>
     </Automotive>    
     <Movies>
           <Name>boxofficereport</Name>
           <Name>movies</Name>
           <Name>imdb</Name>
           <Name>mgm</Name>
     </Movies>
     <Jobs>
           <Name>job</Name>
           <Name>govtjobs</Name>
           <Name>hotjobs</Name>
           <Name>recruitersonline</Name>
     </Jobs>
</WebSites>

websites.xsl

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:template match="/">
          <xsl:apply-templates select="WebSites"/>
             </xsl:template>

     <xsl:template match="WebSites">
          <xsl:apply-templates select="Name"/>
     </xsl:template>

     <xsl:template match="Name">
          <a name="link" href="{concat('http://www.',Name,'.Com')}" target="Mywindow">
          <xsl:value-of select=". "/></a><BR/>
 
     </xsl:template>
 </xsl:stylesheet>
0
Comment
Question by:jas_tvpm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 2

Expert Comment

by:xyzzer
ID: 7986702
Instead of just putting "<a name ...." I do it like this:

<xsl:element name="a">
  <xsl:attribute name="href">
    <xsl:value-of select="tagofurl"/>
  </xsl:attribute>
  <xsl:attribute name="class">
    classnameforcss
  </xsl:attribute>
  <xsl:value-of select="tagoftexttodisplay"/><br/>
</xsl:element>

I guess You could also put Your:
  {concat('http://www.',Name,'.Com')}
or some modification of this instead of:
  "<xsl:value-of select="tagofurl"/>"
Maybe:
  http://www.<xsl:value-of select="Name"/>.com
would work, but as a beginner in xml I'm not sure too
0
 
LVL 2

Expert Comment

by:xyzzer
ID: 7986713
PS there should be something like:
_http://www.<xsl:value-of select="Name"/&gt;.com
in the last line of my prev. comment...

--Filip
0
 
LVL 2

Expert Comment

by:xyzzer
ID: 7986818
Still no good, though You should have no problems deciphering it - I will try again just to lear how to do that in the future:
http:// www.&lt;xsl:value-of select="Name"/>.com
http:// www.<xsl:value-of select="Name"/>.com

Sorry for this...
--Filip
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 1

Expert Comment

by:ksokolowski
ID: 8048702
 XSL that does work for what you want..
  The problem with yours was once the Website template was applied, it was expecting the XML to look like this
<Websites>
    <Name>foo</Name>
</websites>
    When in acutallity the names were underneath their respective sub headings..


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
         <xsl:apply-templates select="WebSites"/>
            </xsl:template>

    <xsl:template match="WebSites">
         <xsl:apply-templates select="Tourism"/>
      <xsl:apply-templates select="Automotive"/>
      <xsl:apply-templates select="Movies"/>
         <xsl:apply-templates select="Jobs"/>  
    </xsl:template>

    <xsl:template match="Tourism">
     <h3>Tourism</h3><br/>
     <xsl:for-each select="Name">
         <a name="link" href="{concat('http://www.',. ,'.Com')}" target="Mywindow">
         <xsl:value-of select=". "/></a><BR/>
      </xsl:for-each>
    </xsl:template>

    <xsl:template match="Automotive">
     <h3>Automotive</h3><br/>
     <xsl:for-each select="Name">
         <a name="link" href="{concat('http://www.',. ,'.Com')}" target="Mywindow">
         <xsl:value-of select=". "/></a><BR/>
      </xsl:for-each>
    </xsl:template>

    <xsl:template match="Movies">
     <h3>Movies</h3><br/>
     <xsl:for-each select="Name">
         <a name="link" href="{concat('http://www.',. ,'.Com')}" target="Mywindow">
         <xsl:value-of select=". "/></a><BR/>
      </xsl:for-each>
    </xsl:template>

    <xsl:template match="Jobs">
     <h3>Jobs</h3><br/>
     <xsl:for-each select="Name">
         <a name="link" href="{concat('http://www.',. ,'.Com')}" target="Mywindow">
         <xsl:value-of select=". "/></a><BR/>
      </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>
0
 
LVL 1

Accepted Solution

by:
ksokolowski earned 300 total points
ID: 8048713
Here is a better way to my above way.. This is more similar to your original one..

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
         <xsl:apply-templates select="WebSites"/>
            </xsl:template>

    <xsl:template match="WebSites">
         <xsl:apply-templates select="Tourism/Name"/>
      <xsl:apply-templates select="Automotive/Name"/>
      <xsl:apply-templates select="Movies/Name"/>
      <xsl:apply-templates select="Jobs/Name"/>
     </xsl:template>


    <xsl:template match="Name">
         <a name="link" href="{concat('http://www.',.,'.Com')}" target="Mywindow">
         <xsl:value-of select=". "/></a><BR/>
 
    </xsl:template>
</xsl:stylesheet>
0
 

Author Comment

by:jas_tvpm
ID: 8055323
Hi sir Thanks for the pgm.the modifications u made works better
0
 
LVL 1

Expert Comment

by:ksokolowski
ID: 8058641
 Please accept my comment as an answer if I have been of help to you!  Thanks!!
0
 
LVL 3

Expert Comment

by:FaithRaven
ID: 9307704
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept ksokolowski's comment
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

FaithRaven
EE Cleanup Volunteer
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Six Sigma Control Plans
Starting up a Project
Suggested Courses

777 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