Jump to content

Brig

Members
  • Posts

    12
  • Joined

  • Last visited

Brig's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hi again boen_robot. I'm hopeinig you could answer this one question I have.I have this XSL stylesheet: <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" indent="yes"/><xsl:template match="/rss/channel"><rss version="2.0"><channel><title>Some title</title> <link>Some link</link> <description>Some articles</description> <language>en</language> <lastbuilddate>Wed, 18 Oct 2006 14:57:32 PST</lastbuilddate><xsl:for-each select="item[node()[contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') ,translate('java','ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))]]"><xsl:value-of select="title"></xsl:value-of><xsl:value-of select="description"></xsl:value-of><xsl:value-of select="link"></xsl:value-of></xsl:for-each></channel></rss></xsl:template></xsl:stylesheet> I have linked it in this XML file: <?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?><rss version="2.0"><channel> <title>title</title> <link>Link</link> <description>Latest jobs</description> <language>en</language> <lastbuilddate>Wed, 18 Oct 2006 14:57:32 PST</lastbuilddate> <image> <title>HN</title> <url>Image</url> <link>Link</link> </image>........</channel></rss> The actual query is working fine and it only displays what I want it to but it only displayes it as unformatted text. I want the result to be displayed as structured XML code.Do you know how I can do this please?Btw, I'm still looking into the other solution you gave me with creating a search engine in coldfusion.Thanks a lot again!
  2. Thanks so much for your reply. I will go through what you've written and see how it goes The XML will not be that large. The content of the RSS feed will only be vacancy listings. We have an RSS feed for each department so they never get that large as jobs are being taken of as well as put in the database.Really grateful for all the help! Will let you know how it goes! Thanks!
  3. Thanks agin for your reply!Your first piece of code is brilliant. I'm taking this in small steps as I can feel I'm in over my head with the little knowledge I have With this code I can specify a search word in the code and get the results, <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/rss/channel"><xsl:for-each select="item[node()[contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') ,translate('sql','ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))]]"><p><xsl:value-of select="title"></xsl:value-of></p><p><xsl:value-of select="description"></xsl:value-of></p></xsl:for-each></xsl:template></xsl:stylesheet> This displays all articles that contains the word sql.I've linked the XSL file in the XML document but this turns the XML document into a list with the title and description content. <?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type="text/xsl" href="stylesheet1.xsl"?><rss version="2.0"><channel> Instead of displaying it as a text list as it is now, could it be displayed as an XML document?Really what I want the stylesheet to do is to filter the XML document so it removes all the item elements and what's in them if title or description doesn't match the keyword in the stylesheet. <?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type="text/xsl" href="stylesheet1.xsl"?><rss version="2.0"><channel> <title>Some title</title> <link>Some link</link> <description>Some articles</description> <language>en</language> <lastbuilddate>Wed, 18 Oct 2006 14:57:32 PST</lastbuilddate> <item> <title>First Title</title> <description>Description 1</description><link>Link 1</link> <pubdate>Wed, 18 Oct 2006 14:55:48 PST</pubdate> </item><item> <title>Second Title</title> <description>Description 2</description><link>Link 2</link> <pubdate>Wed, 18 Oct 2006 14:55:48 PST</pubdate> </item></channel></rss> For example if the keyword is "First" it should only display the following, <?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type="text/xsl" href="stylesheet1.xsl"?><rss version="2.0"><channel> <title>Some title</title> <link>Some link</link> <description>Some articles</description> <language>en</language> <lastbuilddate>Wed, 18 Oct 2006 14:57:32 PST</lastbuilddate> <item> <title>First Title</title> <description>Description 1</description><link>Link 1</link> <pubdate>Wed, 18 Oct 2006 14:55:48 PST</pubdate> </item><item></channel></rss> I'm getting quite confused myself so I'm sorry if it doesn't make sense! Thanks again!
  4. Thank you for your reply boen_robot. It's certanly a good step in the right direction If you have the time I would be very grateful if you could help me with some sample code to get me started on this. I will supply as much information as I can.I have a cold fusion script that picks up the article data from an SQL server and turns it into an RSS xml file with the correct RSS format.The output looks like this, <?xml version="1.0" encoding="ISO-8859-1"?><rss version="2.0"><channel> <title>some title</title> <link>some link</link> <description>some description</description> <language>en</language> <lastbuilddate>Wed, 18 Oct 2006 14:57:32 PST</lastbuilddate> <image> <title>HN</title> <url>some url</url> <link>some link</link> </image> <item> <title>Title 1</title> <description>Description 1</description><link>Link 1</link> <pubdate>Wed, 18 Oct 2006 14:55:48 PST</pubdate> </item> <item> <title>Title 2</title> <description>Description 2</description><link>Link 2</link> <pubdate>Wed, 18 Oct 2006 14:43:21 PST</pubdate> </item> How would I do to use the contains function you described with this RSS feed?And where would I put the translate to same case function you described? //title[contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') ,translate('Web Developer','ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))] If I could just the query function working it would be a big step.The next step after that will be to pick up the search string that the user puts in the search engine and then put that string into the contains function, //title[contains(.,'Whatever the users searched for')] Would this be possible?Thank you so much for your help!
  5. First, I'm a total newbie when it comes to XML and XSLT.I've gotten the task of trying to find out how to build a dynamic RSS feed for our website's search function.The way it should work when it done,A user can search a database of articles. If the user searches for the words 'web developer' he will get a list of results. Here is where the RSS feed comes in.On the result page there should be an option to subscribe to this search as an RSS feed.(It should work exactly like the RSS button on this search engine.)I've got the RSS feed working so I can get a feed of all the articles. I need to find out how to query this RSS feed/XML document to be able to build a feed that displays only articles that contains the words that the users searched for.Could I use XSLT and XPath to accomplish this?I've experimented a bit with XPath and I can query the RSS XML file and get results but only if the query words exactly matches the word in the XML file.The output also needs to be in an RSS 2.0 format. I think this is where I would use XSLT?Sorry for the long post. I've been searching the web for how to do this for over a week now and is starting to get a bit desperate Any help or directions in the right way would be greatly appreciated.Thanks!
×
×
  • Create New...