Ninjakreborn Posted January 26, 2007 Share Posted January 26, 2007 Ok, I have a current system from someoneData feed (xml based datafeed)Current program* He manually get's the xml file from the site, and updates it everyday* The "system" on the site does the following * Xsl file to format (show) the xml in readable format (for viewing the data through a browser) * PHP reads the xml file, and hte xsl file and parses it, adn shows it all onto the pageAdvice needed.I am wondering, should i keep the current system, build onto it, take some time to get into xsl (someone said doing xml you will know to know xsl at some point)Or do I convert the entire system, and let php parse (format), the xml file and display everything with that instead.Or better yet, pull the xml file, database it, and then run off the database. Whenever the cron job run's the php script, dump that table (with xml data), and repopulate it, so it stays up to date.Advice appreciated? Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 26, 2007 Author Share Posted January 26, 2007 Ok, instead of asking a rambled, stupid mixture of questions, let me ask one to save time, and really get me the only answer I need to move forward.Ok, there is xml, there is php, and there is xsl.What exactly is the purpose of ever using xsl to format xml documents, when PHP can be used to do the whole process instead, without any help from XSL?The reason I am asking that question is his current system has the menu.xml file, it has a menu.xsl file where I see it creating all the output for the browser, then a menu.php page bringing it all together, and outputting it.Why not just simply use PHP to open the xml file, parse it, and format it.Or is there something I am missing, that one question should allow me to dig further to find all my other answers. Thank you? Quote Link to comment Share on other sites More sharing options...
ober Posted January 26, 2007 Share Posted January 26, 2007 That's like asking what the point is in creating CSS files when you can use attributes and inline css to get the job done. Everything has a purpose! Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 26, 2007 Author Share Posted January 26, 2007 Ok, so what would you do.Let me ask it this way.You were getting a live feed of something, say new's, or tv listings, or anything like thatYou had some way you were retrieving a file (that is seperate, he uses a program, get's the file and put's it on the server)So we are at the stage where the .xml file is actually on the server and ready to use.Would you use option 1 or 2:1. Use xsl to format the data in the xml file, then use php to combine and output it, which is what is being used now. * Keep in mind I have to be able to make really large changes, build login system, and membership and lot's of other stuff around the xml data. Allow people to remember preferences (favorite choices and everything), based on the xml data.XML + XSL (+PHP) = Output2. Use php to open the xml file on the server, have php parse it all, then output it into the xhtml file using arrays (By trapping parameters into the arrays.) This would mean instead ofXML + PHP = OutputWhich one of the 2 would you prefer. Quote Link to comment Share on other sites More sharing options...
ober Posted January 26, 2007 Share Posted January 26, 2007 I don't know really... that's not enough information for me to tell what is really going on.Example: I parse a feed from another site into a div on one of my customer's sites. It's just a simple link/description feed so I do all the styling with CSS. But I don't know what you're storing in the XML or how you're using it. I also don't know why you'd copy a feed to your server before parsing it. You normally just grab it on the fly and parse it. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 26, 2007 Author Share Posted January 26, 2007 oklabs.zaptoit.comThey provide a live feed for television listings.The guy (I can't disclose any url's or any name's, or any specific's, however a lot of people use the feed, so I can give general information.)Ok, he is getting the data from there. He is using something called "xmltv" to get the xml file, and bring it onto the server. This represents one problem, because he want's it automated, one thing I am trying to look into is setting up a cron job, and have php grab the file daily (Not sure about this yet), that is the second step.For now we have the xml file and he can do it manually until we get to that stage (he has been.)So at this stage, we have the xml file. He has something worked out right He didn't know development he was just hobbying, so he setup something for now.He currently has something setup.After he manually get's the xml file on the server. He has a menu.xml which is the file that holds the xml file, and he has menu.xsl which is xsl giving a bunch of formatting to the xml. Then he has a php page, that is doing some stuff to the xml/xsl file's and outputting them onto the browser, in a table, with some checkboxes, (which is where they see the listings).Enough said about that.Now he is wanting updates to this, login sytem built in, new column of data. This is going to be a full blown application, with a list of about 25-30 different standalone additions he wants built into the application as well as the application went through, commented some and the coding commented.Should I * Pick up some xsl, and style the current sheet to add the other row of data, and modify it as I go* Throw away the xsl stylesheet, and just format everything using php.I have to be able to use this xml data in other ways. Like have user logins, and they they can save there favorite stuff, adn other stuff they can do with the data.I am a little lost as to how to approach this, how would you approach it. Quote Link to comment Share on other sites More sharing options...
ober Posted January 26, 2007 Share Posted January 26, 2007 If this is a feed... I don't understand how you plan to use that to store information about favorites and logins and whatnot. That should be completely seperate and the feed should be parsed in a read-only manner.Again, the styling is up to you. I think you need to look into XSL and make the decision on your own. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 26, 2007 Author Share Posted January 26, 2007 I have been looking into xsl all day.This is the thing, the whole site is based around this feed. People who sign up are going to do things based on this information.THe url was labs.zap2it.com gave you the wrong url a minute ago.I am wondering what is the next step.Is there something I am missing, so I should go ahead nad keep the xsl stylesheet.Could I do the whole thing in php, including the formatting, or should i take all teh data nad put it into mysql.any advice is appreciated thanks. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 26, 2007 Author Share Posted January 26, 2007 Also the application deals with the xmlf ile. THe xml contains live television listings. The programming he is creating, is meant to allow people to browse those listings, and do things with them. Sort of like an online tvguide listings (I see them all over the place), people have done it on other site's.So the idea is to allow people to have a login, be bale to choose there favorites, otehr things, I can't disclose for later functionality. However you get the idea the application need's to be scalable I need to guide it in the direciton so it'll be easy to add in new features in the future, and do new things with it, if needed, and build new things onto it, as needed, with less hasstle. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 26, 2007 Author Share Posted January 26, 2007 Ok, what is hte different between XSL and XSLT Quote Link to comment Share on other sites More sharing options...
zq29 Posted January 26, 2007 Share Posted January 26, 2007 I built a "weekend project" very similar to what you're describing with 7-day TV listing feeds, user accounts, scheduling and email/SMS reminder functions etc. I grabbed an XML file daily and populated a MySQL database with the contents. I wouldn't suggest grabbing and parsing the XML on the fly for every request, I'm sure the person hosting the feed wouldn't be too happy... Quote Link to comment Share on other sites More sharing options...
effigy Posted January 26, 2007 Share Posted January 26, 2007 [quote author=businessman332211 link=topic=124191.msg514327#msg514327 date=1169846205]Ok, what is hte different between XSL and XSLT[/quote]This is often confusing. See if [url=http://sourceware.org/ml/xsl-list/2000-09/msg00730.html]this[/url] helps. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 26, 2007 Author Share Posted January 26, 2007 Hmm, thanks a lot for that.That linked help me understand it.It seems xml/xsl are a lot easier than I thought, I have done a few things.I have a quick question though.You use [code]<xsl:value-of select="$start"/>[/code]Inside of XSL to grab the contents of an xml tag it seemsSo if there was tag like[code]<hello>hi</hello> (just an example)[/code]Then if you use[code]<xsl:value-of select="$hello"/>[/code]Then it seem's it's going to print hi out to the screen.how do you grab the attribute of something.For instance you have an xml file like[code]<user> <firstname>Joyel</firstname> <lastname>Puryear</lastname <age>23</age> <hobbies number="1" time="5">Video Games</hobbies> <hobbies number="2" time="3">TV</hobbies> <purpose>Eat Cheese</purpose></user>[/code]Now, based on what I have seen, I know how to grab something like the age, or the username.using xslHowever I Don't know how to grab something like the value of number, or time.Like here for the first number=1 time=5I need to be able to grab the time, grab the numbersomething like that, I have to grab a start time and a stop time, and compare them.First I need to get access to the variable, I can tell how to do the rest after that.Thanks? Quote Link to comment Share on other sites More sharing options...
effigy Posted January 26, 2007 Share Posted January 26, 2007 XSLT can be tricky at times, but it's an impressive tool. When you use "$hello" in XSLT, you are asking for a variable named "hello", not a tag named "hello". Attributes are prefixed with "@", such as "@color". Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 26, 2007 Author Share Posted January 26, 2007 Ok, that makes sense.So far I have what I wnated done, except for one thing. I know right now, I have a list of programsI need to run through a list of all the programs that are playing under each channelI need to check the start time, and stop time of each show, and if the current ime, is within that time period display what is now playing.So far I have[code] <td><xsl:if test="$start-time <= $time"> <xsl:if test="$stop-time >= $time"> <xsl:text disable-output-escaping="yes"><span class="current"></xsl:text></xsl:if><xsl:if test="@start <= $time"> <xsl:if test="@stop >= $time"> <xsl:text disable-output-escaping="yes"><span class="current"></xsl:text></xsl:if> </td>[/code]I know I need foreach in there, I also have to call out the name of the program that is now playing.So far what I have tried to do is test the start time and stop time, this allows the current tag to display and show it there. I am missing something.Ok so far I have a list of all the channels. Down the list, on each chanel it displays the channel icon, number, name. I need it to check the programs under that channel, and always display the program that is currentl playing for that channel??Again, after talking with redbullmarky for general stuff, I know that studying a lot isn't going to get me anyway. So now I study when I have time, and spend most of my time, shutting up and jumping in. I did htat so far, and made a lot of progress, I am still trying to figure out how I need to go about doing this, any feedback, links, or anything would be greatly appreciated?I don't need links on general xsl, because I have like 4 reference site's up as I learn the syntax while I go along. I ahd actually just found outa bout the @ symbol for attributes when you mentioned that.I just don't understand how to do this process. Right now it's going through all teh channels,It has setup a table, for each channel it shows the information I mentioned, the last thing I need to do here, is get the current programming that is playing (it's name), to appear in the right table cell?I don't understand how to check through all the programms under each chanel, and output the name of the current playing one. Each program has a start time and stop time, I already captured the current time in php using[code]$time = strftime("%Y%m%d%H%M");[/code]I am 100% I can use this as a reference to the current time.(Based on the way the time's are formatted in the xml document.Thanks? Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 26, 2007 Author Share Posted January 26, 2007 Based on what I said above, this is what I created.[code] <td> <xsl:text disable-output-escaping="yes"><span></xsl:text><xsl:for-each select="tv/channel"> <xsl:if test="@start <= $time"> <xsl:value-of select="programme/title" /> </xsl:if></xsl:for-each><xsl:text disable-output-escaping="yes"></span></xsl:text> </td>[/code]Ok the idea is to output the start of the cell.Ok this is the big picture, the current program is already running a foreach for each channel (meaning it goes through each channel), I am trying to run a foreach inside a foreach.Now inside the foreach chanel, I need to run a foreach for all programs in each channel as it goes through.Which is what I attempted to do above.THen for each passthrough on the programmes, it needs to test if the start time, is after the current time, then if it is display the program. I need to1. Get this to work (it's not outputting anything)2. Get it to run this loop, but test for 2 things, make sure the start time is after the current time, and the stop time is before the current time to guarantee that it's the current playing program.Anyfeedback is greatly appreciated.I am running out of stuff to try. Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted January 26, 2007 Share Posted January 26, 2007 * i'm moving this to Application Design as i think the topic in general has bought up some pretty interesting and useful points. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 26, 2007 Author Share Posted January 26, 2007 After doing some more research into directoriesI created this[code] <td> <xsl:text disable-output-escaping="yes"><span></xsl:text> <xsl:for-each select="./programme"> <xsl:if test="@start <= $time"> <xsl:if test="@stop >= $time"> <xsl:value-of select="programme/title" /> </xsl:if> </xsl:if> </xsl:for-each><xsl:text disable-output-escaping="yes"></span></xsl:text> </td>[/code]Where it mentions the directories it seems related to a web directionwhere / is from the rootand ../ is up one level.I modified it as above, and still no luck Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 26, 2007 Author Share Posted January 26, 2007 Ok, another update to the code. Now I haveAfter some more checking, and working with the code, I know this is closer than what I had it.See there is a foreach going through the channel, the programme is seperate. It's below that.So I pass it the chanel id I have, to try and look through, and locate the channel. The foreach program in that channel, go through test for the statements to find the one that is now playing.However htere is still no output, so there is still something I am missing.Any feedback or advice, or help would be greatly appreciated. Thanks.[code] <td><xsl:text disable-output-escaping="yes"><span></xsl:text><xsl:when test="@channel = $channelCode"> <xsl:for-each select="tv/programme"> <xsl:if test="@start <= $time"> <xsl:if test="@stop >= $time"> <xsl:value-of select="programme/title" /> </xsl:if> </xsl:if> </xsl:for-each></xsl:when><xsl:text disable-output-escaping="yes"></span></xsl:text> </td>[/code] Quote Link to comment Share on other sites More sharing options...
effigy Posted January 29, 2007 Share Posted January 29, 2007 That's too many paragraphs and misspellings for me to go through on a Monday morning. I suggest going through [url=http://w3schools.com/xsl/xsl_languages.asp]this[/url] tutorial first. If you still have difficulty, post some sample data, your code, and a brief description of what you need--start with the small stuff first. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 29, 2007 Author Share Posted January 29, 2007 Ok, I foudn out it was impossible to do it the way I was trying.I am trying something else now* calling one xml/xsl file forming them together to create one table of information.* Calling the other xml/xsl file and forming them together and outputting them on the screen after that.* Put both smaller tables into a bigger table to make them look like they are together* Then advance on it from there.I was trying to call information from 2 different xml file's using 1 xsl file, I found out you can't have an xsl file formatting information from one xml file, adn then stop, pull some info from /format some data from another file, continue where it left off, then output all the information together I saw no physical way to do that. If I run into that other problem with this method I will post it here, I am doing that later today. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 29, 2007 Author Share Posted January 29, 2007 Ripping up multiple xml files.I have 1 xml fileIt has a list of information on various "channels" for tvEach of those channels has there own xml file.Each file is named differently. I need to do the followingI have a list already displaying all the channles, there icons and other things.WHich works fine, I am trying to create another xsl file to go through all the channel xml file's. 1 xml for each channel, with all the programs. I need to make it find the now playing program (the program that is currently playing), and show it.Hwo do I get 1 xsl file to check multiple (50) differentWEll like thisTell xsl to do thisLook at channel1.xsllook at all the programspick the one that is currently playing (using math to figure that out)Display the one playing in a table cellLook at channel2.xsllook at all the programspick the one that is currently playing (using math to figure that out)display the one playing in a table cellLook at channel3.xsl look at all the programspick the one that is currently playing (using math to figure it out)display the one playing in a table cellSo on and so forth through all the channel file's.How can I accmplish this using xsl? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.