Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Processing XSLT with PHP Problem

    From what I understand, browsers sometimes display extra space between table rows if there is a newline after a </td> tag. It seems that this should fix the problem:

    <xsl:output method="html" encoding="ISO-8859-1" indent="no" omit-xml-declaration="yes"/>
    <xsl:strip-space elements="*"/>

    but when I view source, my code is still being indented. I think the problem must be in the way the php must be processing the template.

    Here is my processing code:

    $xsl_file = $config[ 'PATH_TEMPLATE' ]."/$file";
    $arguments = array(
    '/_xml' => $xml,
    );
    $xh = xslt_create();
    $result = xslt_process($xh, 'arg:/_xml', $xsl_file, NULL, $arguments);
    if ($result) {
    print $result;

    }
    else {
    print "Sorry, sample.xml could not be transformed by sample.xsl into";
    print " the \$result variable the reason is that " . xslt_error($xh) .
    print " and the error code is " . xslt_errno($xh);
    }
    xslt_free($xh);

    Anyone have any ideas?

  • #2
    Regular Coder
    Join Date
    May 2004
    Location
    sweden
    Posts
    236
    Thanks
    0
    Thanked 0 Times in 0 Posts
    When you look at your source how are you doing it? I believe that IE an maybe mozilla have have auto formatting of XML. Does the source look the same if you save the output to a text file and view it with notepad?
    Carl McDade
    _____________
    Hiveminds Magazine
    for web publisher and community builders
    eRuby Tutorials

  • #3
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The output does look the same either way. Ack...this is driving me nuts.

  • #4
    Regular Coder
    Join Date
    May 2004
    Location
    sweden
    Posts
    236
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do a lot of text file manipulation. There are some PHP functions that add a \n or &nbsp;\n to the end of a line when reading files. Try using trim() on all your strings going in and coming out.
    Carl McDade
    _____________
    Hiveminds Magazine
    for web publisher and community builders
    eRuby Tutorials

  • #5
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Got it working...

    This did the trick:

    $result = xslt_process($xh, 'arg:/_xml', $xsl_file, NULL, $arguments);
    if ($result) {
    $result = preg_replace( "/>\s*</", "><", $result );
    echo ( $result );
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •