XSL Need Help Translating XML To HTML Hyperlink

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > Miscellaneous Scripting Languages & Ideas

XSL Need Help Translating XML To HTML Hyperlink

qwijibow
Sorry if this sounds stupid, but im new to XML, and i just cant get my head around this problem.

imagine the following XML

CODE

<student name=chris>
 <link>http://.chris.com</link>
<student>



i need to use XSL to translate that to a html hyperlink in the form of

CODE

<a hreh="http://chris.com">chris</a>



at first i tried


CODE

<a href="
<xsl:value-of select="student/link"/>
">
<xsl:value-of select="student/@name"/>
</a>



but that generates a nasty error, obviously because i have embedded tags.

how am i meant to solve this problem ????

i have tried storeing "chris.com" in a xsl variable, but then all i get is a hyperlink to a variable name.

google is clueless, does anyone here have any idea's ??

 

 

 


Reply

rkage
Sorry about the long wait for a while. I was stomped on this one last night and my connection went off so I couldn't get to do any more testing, but I remembered how to do what you want.

For the sake of completion, here is the XML file I used;
CODE

<?xml version="1.0"?>

<?xml-stylesheet type="text/xsl" href="links.xsl"?>

<students>
<student name="Chris">
 <link>http://www.chris.com</link>
</student>

<student name="Kage">
 <link>http://kage.astahost.com</link>
</student>
</students>


So to do what you want, just assign the tag <a> and then use the <xsl:attribute name=" "></xsl: attribute>Text for link here</a>

So the complete code I used is;
CODE

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"                            
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<body>
<xsl:for-each select="students/student">
<a><xsl:attribute name="href">
      <xsl:value-of select="link"/></xsl:attribute>
      <xsl:value-of select="@name"/>
      </a>
     <br />
</xsl:for-each>
</body>
</html>
</xsl:template>

</xsl:stylesheet>


Hope this helped. It certainly relit a spark in my head about XML. If you've any qu's in the future on XML, just give me a buzz.

 

 

 


Reply

rkage
Woops, almost forgot, if you want to see the thing in action, click here example.

Reply

qwijibow
Thanks, thats exactly what i needed, i didnt even know htat xsl:attribute existed.


Reply

rIxXoN
Maybe you should read this?:

http://www.astahost.com/Converting-HTML-ov...XHTML-t501.html

I hope this helpd you.

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. xml code hyperlinks - 182.72 hr back. (1)
  2. xsl transformation "xml attribute" - 185.59 hr back. (1)
  3. xslt hyperlink - 195.27 hr back. (1)
  4. xsl xml tag sometimes hyperlink - 196.26 hr back. (1)
  5. xsl embedded hyperlink - 196.88 hr back. (1)
  6. xslt xml text hyperlinks - 206.97 hr back. (1)
  7. xsl template to create hyperlinks - 218.97 hr back. (1)
  8. xslt with html hyperlink - 252.67 hr back. (1)
  9. how do i setup a hyperlink on xml - 267.90 hr back. (1)
  10. xsl html hyperlink
  11. hyperlink xml xsl - 320.39 hr back. (1)
  12. hyperlinks in xslt - 324.23 hr back. (1)
  13. xml hyperlink - 335.98 hr back. (1)
  14. xsl output html hyperlink - 345.37 hr back. (1)
Similar Topics

Keywords : xsl, translating, xml, html, hyperlink

  1. XSL (Help Converting XML To HTML <img Src=> Tags)
    (3)


      Looking for xsl, translating, xml, html, hyperlink

Searching Video's for xsl, translating, xml, html, hyperlink
advertisement




XSL Need Help Translating XML To HTML Hyperlink



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE