dumping xml and xsl for PHP and MySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • davids58@gmail.com

    dumping xml and xsl for PHP and MySQL

    I currently create sites using xml and xsl to produce .html files. I'm
    thinking about using PHP and MySQL instead for performance reasons. Is
    there a way of using PHP to create a set of .html files in batch that
    can then be hosted on a server? The server in question doesn't
    necessarily support PHP.

    Thanks in advance,
    David

  • bobzimuta

    #2
    Re: dumping xml and xsl for PHP and MySQL

    davids58@gmail. com wrote:[color=blue]
    > I currently create sites using xml and xsl to produce .html files. I'm
    > thinking about using PHP and MySQL instead for performance reasons. Is
    > there a way of using PHP to create a set of .html files in batch that
    > can then be hosted on a server? The server in question doesn't
    > necessarily support PHP.
    >
    > Thanks in advance,
    > David[/color]

    All depends on what hat kind of data you're using. If it's static, I
    would just write out straight (X)HTML and use CSS to style it.

    What kind of data are you wanting to use MySQL to store?

    If you're looking to create separate components (say header, footer,
    sidebar) and then inject them into each page, then you can write those
    as HTML files, and in each php page

    require_once( 'header.html' );
    require_once( 'body.html');
    .....

    Comment

    • davids58@gmail.com

      #3
      Re: dumping xml and xsl for PHP and MySQL

      No, I'm talking about a technical specification encompassing thousand's
      of pages.

      David

      Comment

      • Jerry Stuckle

        #4
        Re: dumping xml and xsl for PHP and MySQL

        davids58@gmail. com wrote:[color=blue]
        > No, I'm talking about a technical specification encompassing thousand's
        > of pages.
        >
        > David
        >[/color]

        David,

        You could generate them statically and upload them. But personally I'd get a
        server which supported PHP.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • davids58@gmail.com

          #5
          Re: dumping xml and xsl for PHP and MySQL

          So, how would I go about creating them statically using PHP and MySQL?

          Comment

          • bobzimuta

            #6
            Re: dumping xml and xsl for PHP and MySQL

            davids58@gmail. com wrote:[color=blue]
            > So, how would I go about creating them statically using PHP and MySQL?[/color]

            There are a few options to parse XML. I like the DOM functions
            [http://us2.php.net/manual/en/ref.dom.php] or even SimpleXML
            [http://us2.php.net/manual/en/ref.simplexml.php] if you have php 5.
            They'll let you access the nodes of your document, so then you can put
            the data inside your HTML tags.

            If the document is static, there's no use using MySQL since it's extra
            load and processing time. Better to leave the XML in it's source form.

            But even so, if the document is indeed static, it's really best to use
            the XML parser and write the HTML out to text files, so that you'll
            never have to do it again.

            Comment

            • davids58@gmail.com

              #7
              Re: dumping xml and xsl for PHP and MySQL

              The specification a living document and so is updated all the time. I
              was interested in using PHP and MySQL for performance reasons. My guess
              is that using the XML parser would not provide the benefit I'm looking
              for.

              When I generate the HTML currently, I use the
              org.apache.xala n.xslt.extensio ns.Redirect xml extension. Is there a
              similar extension to PHP that I would use to redirect the PHP output to
              an HTML file rather than just serving the .php via the server?

              Thanks in advance,
              David

              Comment

              • rlee0001

                #8
                Re: dumping xml and xsl for PHP and MySQL

                David,

                php.exe outputs HTML to a file by default. Download PHP locally (you
                won't need Apache or anything else). Install the application. It will
                install a "php.exe" file. You run it from a DOS prompt using something
                like:

                php.exe myscript.php > mypage.htm

                php.exe will run myscript.php and send the output to mypage.htm.

                -Robert

                Comment

                • davids58@gmail.com

                  #9
                  Re: dumping xml and xsl for PHP and MySQL

                  Great. Now, with my xsl code, I have one stylesheet that creates a page
                  for *each instance* of a particular type of xml element, e.g., foo. It
                  sounds like the method you mentioned assumes a 1:1 correspondance bw a
                  ..php and .html. That won't work for my application as there can be
                  thousands of foo's. Is there another approach that might?

                  TIA,
                  David

                  Comment

                  • rlee0001

                    #10
                    Re: dumping xml and xsl for PHP and MySQL

                    David, if your xsl solution works for you, why switch over at all?

                    My understanding is that your server is 100% static and does not
                    support server side scripting and that you are doing the XML/XSL ->
                    HTML translations prior to uploading the static HTML to the server. Is
                    that correct?

                    Also, currently you have 1 XSL file and 1 XML file right? That single
                    XML file contains thousends of "foo"s and each one needs to end up in a
                    seperate HTML file once translated, is that correct? If so how have you
                    been doing that with XSL? Does XSL not assume a 1:1 ratio of XML input
                    to HTML output files?

                    -Robert

                    Comment

                    • davids58@gmail.com

                      #11
                      Re: dumping xml and xsl for PHP and MySQL

                      Robert,

                      As I mentioned before, I'm using a redirect feature implemented at
                      org.apache.xala n.xslt.extensio ns.Redirect and redirecting to a new html
                      file upon every iteration through a xsl:for-each loop on all foo's. An
                      equivalent PHP function is what I'm looking for.

                      XML processing is relatively slow and the processing of many different
                      xsl stylesheets (there's a lot more to the data than just foo's and the
                      stylesheets sometime incorporate fairly complex XPATH statements) takes
                      a couple of hours and I'm concerned about scalabilty.

                      I currently start by transforming the native markup of a UML modeling
                      tool we're using into a body of xml that conforms to my own schema. I
                      then transform that into the HTML as I've described above. I'm
                      currently considering whether it might be better to simply convert the
                      tool's native markup into SQL statements with which to construct a
                      database and then using PHP to generate the static pages more quickly.

                      So there you have the whole story. Thoughts?

                      Thanks again for your interest,
                      David

                      Comment

                      • rlee0001

                        #12
                        Re: dumping xml and xsl for PHP and MySQL

                        David,

                        PHP is not a translation language, it's a full blown programming
                        language with full file IO capabilities so PHP can certainly handle the
                        task at hand. The PHP manual is a great place to look. For example, see
                        here: http://www.php.net/manual/en/function.fopen.php (that is the PHP
                        function to open an external file for reading or writing).

                        I think what you want to do is populate a MySQL database with your XML
                        data. Do you know how to do this? Then create a PHP script to run
                        queries against the database to create the HTML pages. Also, since you
                        are not running these translations on the server, you are not in any
                        way restricted to using PHP. If you have Microsoft Office, you could
                        just as easily use a native windows application (your_program.e xe) and
                        an access database for example. That would probably be easier as there
                        is less overhead involved for you. MySQL is a big pill to swallow for
                        just one app. :o)

                        Since you don't know much PHP you might want to hire a professional
                        coder to implement the project. Your project really isn't that complex
                        but the amount of experience its going to take to do this yourself is
                        way beyond what I can teach you. Rent-A-Coder is a good place to check.
                        I've been programming on there for a while and most of the guys there
                        are very smart and not too expensive. I'd probably charge in the $500
                        range and the project shouldn't take more than a day or two to
                        complete. Don't pay more than that.



                        My coder username on rent-a-coder is rlee0001 and you have my offer
                        above.

                        If you really want to do this yourself, look through the manual at
                        http://www.php.net/ (this is where you download PHP too). If you need
                        help setting up PHP and MySQL and using the manual let me know and I'll
                        try to help.

                        -Robert

                        Comment

                        Working...