xml and xslt transforms

Discussion in 'Scripting & Programming' started by ffreeloader, Oct 23, 2007.

  1. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    I have a question here about the subject of this post.

    I'm setting up Apache to do an xslt transform on an xml document that the web application downloads from another website. The way it's supposed to work is that a php script contacts the other website, downloads the needed data in an xml format, and then the same php script calls an xslt transformation and the data is supposed to be passed on in a web page to our client. Somewhere in there the process is breaking down.

    Looking at the phpinfo() output from a web server that works and one that doesn't, all the same xml-related technologies are enabled on both web servers(there are a couple of version number differences though. The server that is not working has newer versions.). The correct modules(mod-xslt) are loaded on both servers. I can verify this through phpinfo(), running "apache2 -D DUMP_MODULES" on the servers, and by running "strace" on the Apache executable. I have also added the mime types and output filters that I can see should be involved(xml, xsl, xhtml-xml) in the configuration files for the Apache server that isn't working correctly.

    What I don't understand at all is xslt transformations. Anyone have some decent resources I can study on this? Can anyone look at the above and tell me what types of options I'm missing in my configuration? I know this is really sparse information but I'm ignorant enough on this subject, even after reading the documentation for mod-xslt, that I'm having trouble visualizing how this is supposed to work so that I can troubleshoot it.

    I've never even looked at xml other than to see what a the format of an xml document looks like, so as you can see I'm about a mile over my head on this one.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  2. dmarsh
    Honorary Member 500 Likes Award

    dmarsh Petabyte Poster

    4,305
    503
    259
    Don't worry freddy its really quite simple, it just looks complicated. :D

    XML -> XSLT Transform -> Something Else

    The XSLT is used as a general purpose conversion langauge in general, it can take valid XML and output anything you like.

    In this case you have :-

    XML -> XSLT -> HTML

    You also have some complications in that you have a distributed system based on HTTP, this is a seperate matter really and you just need to make sure the comms is set up right and working.

    http://www.w3schools.com/xsl/
    http://www.w3.org/TR/xslt

    Once you understand it its quite basic, you create a transform that matches your document, theres generally match expressions that make parts of the XSLT 'match' or 'fire' these parts then generate output in the output document. The match expressions are a bit like Javascript DOM and regex combined, they are called XPath.

    If your used to rules or predicate based systems and DOM alot of it should be easy to pick up. Even some build systems bear some resemberlance.

    XSLT has various versions, the support for new tags/elements varies with the version, an older XSLT processor may not support the new tags.

    Generally each programming language has its own XML parsers and XSLT processors because of the language binding that is required. You can also run them as standalone programs from the command line, not sure what is happening in you php example.

    Let me know if you need more pointers, I don't use apache much so can't help there...
     
  3. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    Thanks for the links. I've taken a short look at them and they look like they will be a good resource.

    The main problem I've having is that the app is breaking, but no errors show up anywhere. There are no errors in the Apache or PHP logs. If I had some errors, I'd at least know where to start looking. The way things are I will probably have to learn the entire xslt technology just to troubleshoot this.....
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  4. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,624
    117
    224
    If I understand the system correctly - then the PHP module is the key here to debugging it.

    My first attempt to fix this would be to add some debug command to log simple statements like "XYZ routine exited" so as to see where the sites differ.

    What about versions of PHP and Apache on the two machines?

    And there are some environment variables that can change the way PHP works is surprising ways.

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  5. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    Well, there are some minor version number changes. I did make sure the php.ini files were exactly the same on both machines.

    The main problem, as I see it, is that the original site was put together using Xampp which enables every possible option in the entire lamp stack by default, and I'm building servers the other way around--only enabling exactly what we need. This means the original developers didn't need to document what all they had to enable to get this to work. All they did was use a cookbook approach to the xslt transformations until they got something that worked, and now a few years later even that is foggy in their recollections. Thus I'm left to figure out exactly how things work.

    I've run into several problems stemming from how they originally did things, but this one is the toughest, and the last problem left to fix.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  6. dmarsh
    Honorary Member 500 Likes Award

    dmarsh Petabyte Poster

    4,305
    503
    259
    Your best bet is to understand the entire process if possible. You should have some form of logging for PHP and also for apache and possibly seperate logging for each module/plugin and XSLT processor. You can also add debug stuff to the xslt as a last resort, but this will be rendered to the output document in general, and i expect you aren't getting that far?
     
  7. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    That's pretty much the route I'm taking. I'm learning some xml, xsl, xslt, and xpath first--enough to get an understanding of it all--then moving to understanding mod-xslt in Apache2. I have logging going for both php and Apache. I made php log everything, and some null value errors started showing up and stopping the process before I get to the problem I'm working on, so I have wait for the php guy to fix that stuff first before I can go back and work on what I need to. So, I'm in study mode on all of this right now.

    As to your assumption about rendering to the output document, you're correct. That's where the process is visibly breaking. The xml data is being returned from offsite and logged. I can see that much. It's just in the transformation process, or maybe just in the new html page creation that the process is breaking. I don't know enough about xslt's yet to know how to enable the debugging for them, but that's why I'm studying.

    This all doesn't seem to be extremely complicated as I start to understand it, I'm just starting at point 0 as far as all of this is concerned. I have no previous exposure to any of it.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1

Share This Page

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.