Jump to content

boen_robot

Members
  • Posts

    8,493
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by boen_robot

  1. A small note on this... If your PHP page is also the index page, it's not requred to write the full filename of the PHP file. You might as well use the URLwww.mysite.com/?user=#
  2. I suggest that alongside the cookie, you use a GET variable on the targeted page. The PHP will throw English if no GET variable is set and no Cookie is found. The GET variable will ensure the first time the page displays correctly and the cookie will ensure future visits will use the selected language. Btw this method also allows the user to bookmark the page in a language of their choise, instead of relying on the cookie.
  3. XLink and XPointer can help you target the certain word or node, but not to define that word as a link to a target.In other words, a link may target the word "here" without that word having it's own node with(out) ID. However, links can only be defined on nodes. And not any nodes either. Elements only, scince XLink uses attributes and XPointer is part of those same attributes.
  4. The question itself doesn't make any scence. And what place does this have in the XSLT forum if I may ask?
  5. The point I'm trying to make is that probably, the RSS input (the file that XSLT will process) is actually going to be your whole database, right? And you want to filter the whole database for the search term. Well, that's certanly not good, because performance will drop very much with such large documents (if we suppose your database is huge of course).To impove performance, you need to create a search engine with Cold Fusion itself, that will return either the filtered XHTML or RSS intput. For example, you may set Cold Fusion to return the following XHTML page when the search term is "First". <html lang="en" xml:lang="en"><head> <title>Some title</title> <meta name="description" content="Some articles"/></head><body><ul> <li> <p>First Title</title> <p><a href="Link 1">Description 1</a></p></li></ul></body></html> Then, taking this as input, XSLT could create an RSS feed: <?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></channel></rss> And the code for that get's simpler, because you won't need complex filters. A simple: <xsl:template match="ul"><xsl:for-each select="li"><item><title><xsl:value-of select="p[1]"/></title><description><xsl:value-of select="p[2]"/></description><link><xsl:value-of select="p[2]/a/@href"/></link></item></xsl:template> Is all you need to generate the items.This last stylesheet also answers your other question. Yes, the output could be in any XML based format, including XSLT itself.
  6. what @www.mihalism.com just gave is for MySQL databases.For Access in PHP, see the ODBC page. It descibes what you need to do in Access and what in PHP.
  7. The only thing I feel that it's not right is the headers on the center column. The first one is higher then I feel it should be. It should be below the white line that's drawn in the background. In IE7, it's even more shifted above then in Firefox.
  8. Scince there will be more then a single title match in most cases, it's logical to put this statement in a for-each or a template match, and do whatever you want for each match.For example: <xsl:template match="/rss/channel"><ul><xsl:for-each select="item[node()[contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') ,translate('Web Developer','ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))]]"><li><p class="title"><xsl:value-of select="title"></p><p class="description"><xsl:value-of select="description"></p></li></xsl:for-each></ul></xsl:template> In order to be able to adjust the search term, you need to put it as a parameter. Cold Fusion could then change that parameter on run and influence the output. You could also do the same for the upper case and lower case to shorten the XSLT a bit: <xsl:template match="/rss/channel"><xsl:param name="search-term"/><xsl:variable name="upper-case" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/><xsl:variable name="lower-case" select="'abcdefghijklmnopqrstuvwxyz'"/><ul><xsl:for-each select="item[node()[contains(translate(.,$upper-case,$lower-case) ,translate($search-term,$upper-case,$lower-case))]]"><li><p class="title"><xsl:value-of select="title"></p><p class="description"><xsl:value-of select="description"></p></li></xsl:for-each></ul></xsl:template> With this, using a special command in Cold Fusion (I don't know exactly what's that in Cold Fusion though) you can set the parameter to the search term.However, not the idea is a bit clearer, I think I should give you an idea of an alternative approach. Using Cold Fusion, create a page with the results in either XHTML or RSS format. Using XSLT, you can translate the one to the other. The need for the $search-term parameter will not be anymore, scince all of the results in the input will be the desired search results. Infact, that's actually the best approach, because XSLTs performance on large XML files (your whole database) could be really too much for anyone.
  9. Oh... that... I'm starting to see why you needed the complex PHP above .You first need to select the proper node with the XML reader and then replace that node with a new one with the XML writer. The new string will of course be htmlspecialchars($the-old-node).How exactly to do that is another question though. I'm still exploring PHP's XML functions myself.
  10. boen_robot

    Help with FireFox

    Even if you make this script work in FF, the whole application is not runnable, because only IE supports Data Islands.In order for this to have any chnace of working outside IE, the whole JS needs to be completely redone and the <xml> tag along with the datasrc attributes need to go.
  11. Besides the things already mentioned, I think one should also consider the average richness of the people in your area. If a price of ~$50/h is just too much for your customers, even if we assume you have a lot of knowledge and experience, you'll get less (if any) jobs in this area.For example, for my first (and only for now) project, I took a flat fee of 50 BGN which is about 25 euros (calculate the USD yourself). The project was somehow big and included a creation of very innovative things that similar sites have never thought of using. I could have asked for a lot more then what I got, but the circumstances didn't allowed me more:1. The person is a regular customer of the PC assembling shop I work in with my father. Because of that, he knows I'm just beginning to create web sites. I can't even "lie" I'm a professional.2. The creation of the whole thing took about 3 weeks. The used files were 2 images, 5 XMLs, 3 XSLTs, 2 CSS and 2 PHP files. Total of 13 files. Though very flexible and scalable, it simply doesn't look impressive at the beginning, scince there's only a sample content. Not to mention that the speed/qunatity ratio just sounds funny. I mean 6 files (XMLs are just content, images weren't my creations and the PHPs are ~40 almost identical lines of code) for 21 days? How could I ask for more?But most importantly:3. A professional web design company takes a flat fee of about 200 BGN (100 euros) for "small" projects like this one (small becase MySQL is not involved) or something like 5-10 BGN/h for all sizes. If professionals take that much, I as a newbie in terms of marketing can't take that much. And even when I do reach professionalism, I won't be able to get more then that, scince clients will go to those people instead of me. It's just the trend... people either get the cheapest or if they want to look "cool"- the most expensive (thinking this always means the biggest quality, when it truth it only means the most eyecandy).
  12. Scince I don't know the schema, I don't think I could start guessing, but...just a thought... try to remove the first xmlns. The no-prefixed one.
  13. You can use the contains() function to query elements that have a certain word or phrase. For example: //title[contains(.,'Web developer')] Would return true() to all titles that contain the phrase "Web developer", which could include: etc.Note that the above is case sencetive, so it will be false on and there isn't a "straight forward" way for XPath 1.0 to be case insencetive.The only way I can think of with XPath 1.0 is to translate all elements' content to one case and translate the search term to the same case. Comparing those translated strings is like comparing case insencetively.In code, this would be something like://title[contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') ,translate('Web Developer','ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))]
  14. That's one big bunch of messy-and-unfamiliar-to-me code.Your last code: $write_string .= "</whatever>";htmlspecialchars($write_string);$fp = fopen("xml.xml", "w+");fwrite($fp, $write_string) or die("Error writing to file");fclose($fp);print "You did it, way to go!!!"; Should only write the litteral string </whatever> in the end of the xml.xml file, making it a non-well formed XML document.By the way, following the example from the reference, I think this code should look more like: $input_string = "</whatever>";$write_string = htmlspecialchars($input_string);$fp = fopen("xml.xml", "w+");fwrite($fp, $write_string) or die("Error writing to file");fclose($fp);print "You did it, way to go!!!";
  15. boen_robot

    SMS Integration

    There is a PEAR SMS extension for PHP, but it's still a beta. I have no idea how to install it or use it either.
  16. If everything in the environment (XML DOM, XSLT, PHP, whatever) is correct, this should work: /Letter/LetterReport/SummaryInfo/@subAcctName All of what you have suggested should work as well.What code are you using to perform the XPath statement?
  17. boen_robot

    xpath sorting

    XPath 1.0 results are sorted in their document order by default and you can't change that. What you can do in XSLT at least though is to use the <xsl:sort/> element to re-sort the output. In other environments, you'll have to use other equivalents for now.XPath 2.0 and XQuery will provide options for sorting, thus allowing all environments to sort their results, not only the ouput.
  18. Changing the <meta> is not what will break IE, nor is what will change the MIME type. Try it if you don't believe me. What will break IE and what is the correct way of serving XHTML is to set the server to serve files with that MIME type. In Apache's configuration file, this might look like: AddType application/xhtml+xml .html In order to enable this MIME type for every user agent that supports it and use text/html only for IE and other user agents that don't support this MIME type, you need server side scripting.In this topic GT500 shows a simple PHP script to switch between the two and even the DTD if needed. I do reccomend not changing the DTD though. Trying to handle a single piece of code across two MIME types and IE on top is enough trouble as it is.
  19. I think you can with an XPath expression like this: processing-instruction('Insert-Table')/@ID If that doesn't work (as I'm reading one site, I think this might be the case), you must treat the attributes as strings, like this: <xsl:template match="processing-instruction()"> <xsl:value-of select="substring-before(substring-after(., 'ID="'), '"')" /></xsl:template>
  20. boen_robot

    XML PHP Login

    The same way you do an SQL basd login, with the only difference that instead of SQL statements you use XPath or XQuery statements.You translate the inputted value to MD5 (and Salt) and perform an XPath expression with the XML reader to find a matching login/password nodes.But again, how do you hide the XML file and still allow it's usage from local CGI scripts?I was thinkink of something like:<Files login.xml>Order allow,denyAllow from 127.0.0.1Deny from All</Files> As a configuration for Apache, but I'm not sure if it will work. Not to mention it has special requrements for the host (not everyone allows altering the server configuration). And also, if you're on a shared server, this allows the admins to see the password information in plain text (unless of course it's encrypted). Not only that, but it will allow other users on this server to exploit possible security holes in the server to fetch your file. This of course is applicable to MySQL too, which is why sencetive data should always be encrypted .
  21. Here's a cross browser JavaScript to do what you want.
  22. boen_robot

    xpath

    My point was if the highest ID is always the same as the amount of elements. The answer to this question would have been "no" if a possible look of your document was:<test><records><id>1</id></records><records><id>3</id></records><records><id>2</id></records><records><id>5</id></records><records><id>6</id></records></test> The number of <records> is 5, but the highest ID is 6. So my above XPath expression wouldn't have worked properly scince it would return 5 instead of 6.However, you say that this ID is automatically incremented for every new element, right? In that case, the above situation will be impossible, and thus, my suggested expression will do the trick.aalbetski's idea is good too, if you don't mind the extra lines, for the sake of a single value.
  23. I said Oh, for crying out loud:<p>Hello<script type="text/javascript"><!--print_user_name();// --></script><span>dear user,</span>and welcome to our site.</p> If you hide the span's content with JS, then this content won't be hidden when JS is off.
  24. First of all, you adress a variable by the value of the name attribute, not the name attribute itself. So you should adress this variable with "$id", not "$name".Also, a local variable (one inside a template) is only available to it's siblings and descendants. Scince in this example the variable is a child of a <td>, it's available only to that <td> and further down.To make it accessable to other cells, simply move it at least one level above. In other words, create it inside a <tr> like this: <xsl:for-each select="NewDataSet/Table"><tr><xsl:variable name="id" select="Id" /><td style="font-family: Verdana;font-size : 8pt;color:blue"><xsl:value-of select="Id"/>.</td><td> <a href="showCatalog.aspx?id='$id'" class="catalogLink" ><xsl:value-of select="Name"/> </a></td></tr> </xsl:for-each> If that for-each generated more then one row, you may even create the variable as a sibling to the row like this: <xsl:for-each select="NewDataSet/Table"><xsl:variable name="id" select="Id" /><tr><td style="font-family: Verdana;font-size : 8pt;color:blue"><xsl:value-of select="Id"/>.</td><td> <a href="showCatalog.aspx?id='$id'" class="catalogLink" ><xsl:value-of select="Name"/> </a></td></tr> </xsl:for-each> Scince all of those are created for each NewDataSet/Table node, the result is the same.
  25. I think storing data for almost any sort of reason, including a functional one is the purpose of XML. If you use it instead, it will be somewhat easier, scince you'll deal with the elements as individual elements, instead of dealing with the whole file as one big text string.
×
×
  • Create New...