Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsNews FeedsNews FeedsHTML Tags Not working (reprise w/ RDF xsl example)HTML Tags Not working (reprise w/ RDF xsl example)
Previous
 
Next
New Post
6/26/2008 5:02 PM
 

Not sure what happened to the original post from jgurley, so here's a continuation....

The rdf namespace definition includes several other namespaces, among them the rss namespace.  When you refer to an element that you want to use, you need to use the namespaces prefix to find it, which is why we use the rss:description designation.  I know that's brief, but more info is available on other xml/xsl sites. 

Now, one tactic I use to help with layouts, is to just create a simple HTML page with the layout I envision, using just simple text in place of the xml elements I intend to use.  Once I get the layout setup, I can take care of the xml/xsl pieces.  One thing about xsl is that it is very unforgiving of HTML mistakes.  Any HTML you use must be well-formed, otherwise the xml/xsl parser will choke and spit seemingly incorrect error messages. 

It is a pain to translate RDF, so any HTML you use better be well-formed.  Now, I should have told you that I actually, corrected some HTML to get the feed to display after changing the literals to actual HTML tags.  That's probably why you are still having issues.  So, being a bit nerdish, I'm giving you an example that may help get you a bit further along.  Breaking on date is very problematic as xsl scripting is limited due to issues with security, but there are ways to do it using the xml/xsl module, but it involves code changes, which are a bit more involved.

Here's a sample xsl I am using with that feed.  It may not be exactly what you need, but it should give you a bit more bits and tricks to examine.  Anyway, check it out...

Cheers,

iwonder ;-)

<?xml version='1.0'?>
<xsl:stylesheet
  version="1.0" exclude-result-prefixes="rdf rss l dc admin content xsl"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                  xmlns:rss="http://purl.org/rss/1.0/"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                  xmlns:admin="http://webns.net/mvcb/"
                  xmlns:l="http://purl.org/rss/1.0/modules/link/"
                  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<!-- phil 'iwonder' guerra - xsl simple rdf translation file. -->
    <xsl:output omit-xml-declaration="yes"/>
 <xsl:param name="currentDate"/>
    <xsl:variable name="Today" select="$currentDate"/>
    <xsl:template match="/rdf:RDF">
    <html><head></head><body>
    <table ><tbody width="100%">
         <th align="left">Date</th>
   <th align="left">Time</th>
   <th align="left">Tide</th>
   <th align="left">Height</th>
   <th align="left">Event</th>
   
       <xsl:for-each select="rss:item">
        <xsl:variable name="title" select="rss:title"/>
   <xsl:variable name="desc" select="rss:description"/>
         <xsl:variable name="date" select="substring-before($desc,' at')"/>
         <xsl:variable name="mydate" select="dc:date"/>

   <xsl:if test="contains($title,'High Tide')">
    <tr>
     <td><xsl:value-of select="$date" disable-output-escaping="yes"/></td>
               <td><xsl:value-of select="substring-before(substring-after($desc,'at '),': ')" disable-output-escaping="yes"/></td>
               <td><xsl:value-of select="substring(substring-after($desc,'feet '),1,4)" disable-output-escaping="yes"/></td>
               <td><xsl:value-of select="substring-before(substring-after($desc,'T: '),'feet')" disable-output-escaping="yes"/> feet </td>
     <td>High Tide</td>
     </tr>
    </xsl:if>
   <xsl:if test="contains($title,'Low Tide')">
    <tr>
     <td><xsl:value-of select="$date" disable-output-escaping="yes"/></td>
               <td><xsl:value-of select="substring-before(substring-after($desc,'at '),': ')" disable-output-escaping="yes"/></td>
               <td><xsl:value-of select="substring(substring-after($desc,'feet '),1,4)" disable-output-escaping="yes"/></td>
               <td><xsl:value-of select="substring-before(substring-after($desc,'T: '),'feet')" disable-output-escaping="yes"/> feet </td>
     <td>Low Tide</td>
     </tr>
    </xsl:if>

                <xsl:if test="(contains($desc,'Sunrise'))">
      <tr>
       <td><xsl:value-of select="$date" disable-output-escaping="yes"/></td>
                   <td><xsl:value-of select="substring-before(substring-after($desc,'at '),': ')" disable-output-escaping="yes"/></td>
                   <td> ----- </td>
                   <td> ----- </td>
       <td>Sunrise</td>
      </tr>
      </xsl:if>         
                <xsl:if test="(contains($desc,'Moonset'))">
      <tr>
       <td><xsl:value-of select="$date" disable-output-escaping="yes"/></td>
                   <td><xsl:value-of select="substring-before(substring-after($desc,'at '),': ')" disable-output-escaping="yes"/></td>
                   <td> ----- </td>
                   <td> ----- </td>
       <td>Moonset</td>
      </tr>         
                </xsl:if>
                <xsl:if test="(contains($desc,'Moonrise'))">
      <tr>
       <td><xsl:value-of select="$date" disable-output-escaping="yes"/></td>
                   <td><xsl:value-of select="substring-before(substring-after($desc,'at '),': ')" disable-output-escaping="yes"/></td>
                   <td> ----- </td>
                   <td> ----- </td>
       <td>Moonrise</td>
      </tr>
      </xsl:if>        
                <xsl:if test="(contains($desc,'Sunset'))">
      <tr>
       <td><xsl:value-of select="$date" disable-output-escaping="yes"/></td>
                   <td><xsl:value-of select="substring-before(substring-after($desc,'at '),': ')" disable-output-escaping="yes"/></td>
                   <td> ----- </td>
                   <td> ----- </td>
       <td>Sunset</td>
      </tr>         
                </xsl:if>
       </xsl:for-each>
       </tbody></table></body></html>
    </xsl:template>
</xsl:stylesheet>
 

It gives me output something like this:

Date Time Tide Height Event
2008-06-25 5:42 AM PDT ----- ----- Sunrise
2008-06-25 10:52 AM PDT Low 0.62 feet Low Tide
2008-06-25 12:44 PM PDT ----- ----- Moonset
2008-06-25 5:40 PM PDT Hig 6.19 feet High Tide
2008-06-25 8:56 PM PDT ----- ----- Sunset
2008-06-26 12:03 AM PDT Low 2.04 feet Low Tide
2008-06-26 12:47 AM PDT ----- ----- Moonrise
2008-06-26 5:31 AM PDT Hig 4.68 feet High Tide
2008-06-26 5:43 AM PDT ----- ----- Sunrise
2008-06-26 11:34 AM PDT Low 1.24 feet Low Tide
2008-06-26 1:54 PM PDT ----- ----- Moonset
2008-06-26 6:19 PM PDT Hig 6.52 feet High Tide
2008-06-26 8:56 PM PDT ----- ----- Sunset
2008-06-27 1:10 AM PDT ----- ----- Moonrise
2008-06-27 1:11 AM PDT Low 1.32 feet Low Tide
2008-06-27 5:43 AM PDT ----- ----- Sunrise
2008-06-27 6:57 AM PDT Hig 4.37 feet High Tide
2008-06-27 12:24 PM PDT Low 1.87 feet Low Tide
2008-06-27 3:07 PM PDT ----- ----- Moonset
2008-06-27 7:03 PM PDT Hig 6.88 feet High Tide
2008-06-27 8:56 PM PDT ----- ----- Sunset
2008-06-28 1:37 AM PDT ----- ----- Moonrise
2008-06-28 2:16 AM PDT Low 0.48 feet Low Tide
2008-06-28 5:43 AM PDT ----- ----- Sunrise
2008-06-28 8:26 AM PDT Hig 4.35 feet High Tide
2008-06-28 1:20 PM PDT Low 2.43 feet Low Tide
2008-06-28 4:24 PM PDT ----- ----- Moonset
2008-06-28 7:51 PM PDT Hig 7.25 feet High Tide
2008-06-28 8:56 PM PDT ----- ----- Sunset
2008-06-29 2:10 AM PDT ----- ----- Moonrise
2008-06-29 3:16 AM PDT Low -0.38 feet Low Tide
2008-06-29 5:44 AM PDT ----- ----- Sunrise
2008-06-29 9:47 AM PDT Hig 4.58 feet High Tide
2008-06-29 2:24 PM PDT Low 2.84 feet Low Tide
2008-06-29 5:44 PM PDT ----- ----- Moonset

 
New Post
6/30/2008 11:41 PM
 

Thanks for the example.  I had simplified my problem to get rid of the poorly nested HTML to look pretty much like yours.  I think I can get the format I prefer if I can get the following-sibling function to work, but I've spent way to much time"mouse milking" this and will try later when maybe I have a greater need to figure it out.

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsNews FeedsNews FeedsHTML Tags Not working (reprise w/ RDF xsl example)HTML Tags Not working (reprise w/ RDF xsl example)


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out