SunQuest
           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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 5th, 2003, 02:03 PM
krayziekup krayziekup is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Bosie, ID
Posts: 7 krayziekup User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help with simple XSL

I have an XML document, which describes university style guides for web pages. The structure to the document looks like this.

<styleguide>
<rule>
<name>style guide rule</name>
<description>Some content <link href=”some url”>content that is a hyperlink </link> more content</description>
</rule>

<rule>
<name>another style guide rule</name>
<description>Content <link href="some url">content that is a hyperlink </link> More content </description>
</rule>
</styleguide>

My question is how can I retrieve the link information and transform it to a HTML hyperlink? Not all description tags have content that are links but some do. I have read a number of Xpath and XSLT tutorials because I am new to the XML world but I just can’t figure out how to deal with the link element if it exisists within a description element. Any help would be greatly appreciated.

Thanks!

Reply With Quote
  #2  
Old August 5th, 2003, 03:34 PM
Wizard2003's Avatar
Wizard2003 Wizard2003 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 206 Wizard2003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 29 m 24 sec
Reputation Power: 6
Try:
Code:
<xsl:if test="description/link">
  <a href='{description/link/@href}'>
    <xsl:value-of select="description/link/text()">
  </a>
</xsl:if>

Reply With Quote
  #3  
Old August 5th, 2003, 04:06 PM
krayziekup krayziekup is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Bosie, ID
Posts: 7 krayziekup User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the reply. I guess I need to be a little more clear. If my description has a link element in the middle of the content I can get the first part of the content to display and the link element content, but I can't get the rest of the description content to display.
For example:
<description>this is text in my description. <link url="some url">This text is a hyperlink</link> this is more text in my description.</description>

After I run into a link element I can't get the rest of the content in my description tag to appear. Thanks again for the reply. Any help on this would be great.

Reply With Quote
  #4  
Old August 5th, 2003, 05:15 PM
mrusaw's Avatar
mrusaw mrusaw is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Dallas, Texas
Posts: 138 mrusaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to mrusaw Send a message via Yahoo to mrusaw
apply this style sheet against your xml and see if it gives you a starting point. It will work for your xml data as long as it only has one <link> per description. You probably will be able to expand the scale with some time:

Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:for-each select="styleguide/rule">
            <xsl:value-of select="concat('Name:  ', name)" />
            <br />
            <xsl:for-each select="description">
                <xsl:value-of select="substring-before(., link)" />
            </xsl:for-each>
            <xsl:for-each select="description/link">
                <a href="http://{@href}">
                    <xsl:value-of select="." />
                </a>
            </xsl:for-each>
            <xsl:for-each select="description">
                <xsl:value-of select="substring-after(., link)" />
            </xsl:for-each>
            <br />
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>


Let me know if it helps...
__________________
mr...

mike.rusaw@realpage.com
RalPage, Inc.

"I have made this letter longer than usual, only because I have not had the time to make it shorter." - Blaise Paschal

Reply With Quote
  #5  
Old August 6th, 2003, 10:59 AM
krayziekup krayziekup is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Bosie, ID
Posts: 7 krayziekup User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I just ran the style sheet and it works great. I think this will be a good enough starting point for me to figure out how to deal with multiple links are zero links. Thanks for the help and the reply.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Help with simple XSL


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


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





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