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 July 9th, 2003, 03:33 AM
ice_man_82 ice_man_82 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 2 ice_man_82 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Html -> Xml -> Xslt -> Html

Hi, need major help. I got some XML which is basicly html, sample here:

<img src="/images/msword.gif"/>

<a href="ltsfinaljuly02.doc">Word</a>

<img src="/images/pdf.gif"/>

<a href="ltsfinaljuly02">PDF</a>

All i wanna do is in XSLT is check if the "href" link is to a .doc file. if so, add some attributes like target="_blank" and title="This will open in a new page" then output it.

Reply With Quote
  #2  
Old July 9th, 2003, 03:48 AM
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 this:
Code:
<xsl:if test"substring(@href, string-length(@href)-3, string-length(@href))='.doc'">
target="_blank"
</xsl:if>

Reply With Quote
  #3  
Old July 9th, 2003, 03:59 AM
ice_man_82 ice_man_82 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 2 ice_man_82 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
xsl so far

This is the xsl i have so far but it does'nt add the attributes.

<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match="title">
<h3><xsl:apply-templates/></h3>
</xsl:template>

<xsl:template match="a|area">
<xsl: param name="href-uri">
<!-- pdf, doc, ppt, xls target="_blank"-->
<!-- links that start http(s) or got a : do the same -->
<!-- for both above add title attribute "This link will open in a new window"-->
<xsl:choose>
<!-- handles relative URIs for href attributes -->
<xsl:when test="contains(@href, '.pdf') or contains(@href, '.doc') or contains(@href, '.ppt') or contains(@href, '.xls') or contains(@href, ':')">

<xsl:element name = "{//a}" >
<xsl:attribute name = "target" >_blank</xsl:attribute>
<xsl:attribute name = "title" >This link will open in a new window</xsl:attribute>
<xsl:apply-templates />
</xsl:element>

</xsl:when>

<xsl: otherwise>
<xsl:value-of select="@href"/>
</xsl: otherwise>
</xsl:choose>
</xsl: param>

<xsl:copy>
<xsl:attribute name="href">
<xsl:value-of select="$href-uri" />
</xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

Reply With Quote
  #4  
Old July 9th, 2003, 05:11 AM
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
Why do want to write a struture like:
Code:
        <xsl:element name="{//a}" >
          <xsl:attribute name="target">_blank</xsl:attribute>
          <xsl:attribute name="title">This link will open in a new window</xsl:attribute>
          <xsl:apply-templates />
        </xsl:element>


in an attribute?
Code:
      <xsl:attribute name="href">
        <xsl:value-of select="$href-uri" />
      </xsl:attribute>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Html -> Xml -> Xslt -> Html


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 5 hosted by Hostway