XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 4th, 2004, 03:59 PM
glacier6327 glacier6327 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 2 glacier6327 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Creating a Hyperlink in HTML from xml data...

Hello I am an XML newbie, and I have created my first page genrated from xml data using an xsl style sheet.. If I am saying that correctly.

I wish to use the following xml and xsl sytlesheet and have the ip data appear as a hyperlink in the final page with the ip adress and a refrence that is that same data... any help would be greatly appreciated.

Here is My xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Authour: Robert Marchionne -->
<?xml-stylesheet type="text/xsl" href="index.xsl" ?>
<Machine_Listing xmlns:xlink="http://www.w3.org/1999/xlink">
<machine>
<ID>Jayson Barker</ID>
<class>desktop</class>
<model>2645</model>
<type> V4U</type>
<serial>$5.95</serial>
<ip>9.51.62.133</ip> <!-- I want this to appear on my page as a hyperlink to this ip address -->

</machine>
<machine>.....

...</machine>
</Machine_Listing>

Here is my xsl file...

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited with XML Spy v4.2 -->
<HTML xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:12pt;
background-color:#EEEEEE">
<xsl:for-each select="Machine_Listing/machine">
<DIV STYLE="background-color:red; color:white; padding:4px">
<SPAN STYLE="font-weight:bold; color:white"><xsl:value-of select="ID"/></SPAN>
- <xsl:value-of select="class"/>
</DIV>
<xsl:value-of select="ID"/>


<DIV STYLE="margin-left:20px; margin-bottom:1em; font-size:10pt">

<SPAN STYLE="font-style:italic">

(<xsl:value-of select="type"/> model)
<xsl:value-of select="ip"/>
</SPAN>
</DIV>
</xsl:for-each>
</BODY>
</HTML>

Reply With Quote
  #2  
Old August 4th, 2004, 04:22 PM
latrosicarius latrosicarius is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 75 latrosicarius User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 1 m 11 sec
Reputation Power: 5
Send a message via AIM to latrosicarius
Instead of saying this:

Code:
<ip>9.51.62.133</ip>


Say this:

Code:
<ip>&l_t;a href="http://9.51.62.133/"&g_t;9.51.62.133&l_t;a&g_t;</ip>


except where i have an underscore (_) character in the &l_t; and &g_t; things, take out the underscore.

The reason is is that a &l_t; thing means a LESS-THAN sign ( < ) and a &g_t; thing means a GREATER-THAN sign ( > ), but you can't just write them in the XML b/c then the XML will think they are XML nodes.

Unfortunatly, XML does not have a CDATA equivelant for HTML content, so you have to use replacement characters for HTML symbols such as:

&l_t; for <
&g_t; for >
&a_mp; for &
&q_uot; for "
etc. (ALL WITHOUT THE UNDERSCORE CHARACTER)

Hope this helps,
Matt G.

Reply With Quote
  #3  
Old August 5th, 2004, 07:26 AM
NotGoddess's Avatar
NotGoddess NotGoddess is offline
Kung-fu Kitty
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 350 NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 6 h 9 m 2 sec
Reputation Power: 10
Send a message via AIM to NotGoddess
Quote:
Originally Posted by glacier6327
I wish to use the following xml and xsl sytlesheet and have the ip data appear as a hyperlink in the final page with the ip adress and a refrence that is that same data... any help would be greatly appreciated. <ip>9.51.62.133</ip> <!-- I want this to appear on my page as a hyperlink to this ip address -->


PHP Code:
<a>
   
http://<xsl:attribute name="href"><xsl:value-of select="ip"/></xsl:attribute>
   
<xsl:value-of select="ip"/>
</
a


I had to adjust your xsl to make this work, so here is the entire stylesheet:
PHP Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" />
<xsl:template match="/">
<!-- Edited with XML Spy v4.2 -->
<HTML>
<BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:12pt; background-color:#EEEEEE">
   <xsl:for-each select="Machine_Listing/machine">
      <DIV STYLE="background-color:red; color:white; padding:4px">
         <SPAN STYLE="font-weight:bold; color:white">
            <xsl:value-of select="ID"/>
         </SPAN>
         - <xsl:value-of select="class"/>
      </DIV>
      <xsl:value-of select="ID"/>
      <DIV STYLE="margin-left:20px; margin-bottom:1em; font-size:10pt">
         <SPAN STYLE="font-style:italic">
            (<xsl:value-of select="type"/> model)
            <A>
               <xsl:attribute name="href">
                  http://<xsl:value-of select="ip"/>
               </xsl:attribute>
               <xsl:value-of select="ip"/>
            </A> 
         </SPAN>
      </DIV>
   </xsl:for-each>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>

Reply With Quote
  #4  
Old August 11th, 2004, 01:25 PM
glacier6327 glacier6327 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 2 glacier6327 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up That Worked.. Much Thanks NotGodess

That is exactly what i was looking for.. Ty very much

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Creating a Hyperlink in HTML from xml data...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT