Sablotron

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simone

    #1

    Sablotron

    this (my) script i's ok:
    <?php
    $processor=xslt _create();
    $result=xslt_pr ocess($processo r,'xsl/curriculum.xml' ,'xsl/curriculum.xsl' );
    if (!$result) {
    echo xslt_error($pro cessor);
    }
    else {echo $result;}

    xslt_free($proc essor);
    ?>
    ...where files are under c:\PHP directory!

    but this don't work:
    <?php
    $processor=xslt _create();
    $path=dirname(_ _FILE__);
    $tree="{$path}/xml/curriculum.xml" ;
    $transform="{$p ath}/xml/curriculum.xsl" ;
    $result=xslt_pr ocess($processo r,$tree,$transf orm);
    if (!$result) {
    echo xslt_error($pro cessor);
    }
    else {echo $result;}

    xslt_free($proc essor);
    ?>
    ....where files are under the directory where is the script
    ...and the output is:

    Warning: Sablotron error on line 1: XML parser error 4: not well-formed
    (invalid token) in D:\siti\prove\3 _XML\php\curric ulum-sablotron.php
    on line 17 (--> $result=xslt_pr ocess($processo r,$tree,$transf orm); )

    XML parser error 4: not well-formed (invalid token)

    where's the problem?
    why Sablotron takes files only from the directory of PHP?

    thank you!

    Simone





  • Ian P. Christian

    #2
    Re: Sablotron

    Simone wrote:
    [color=blue]
    > this (my) script i's ok:
    > <?php
    > $processor=xslt _create();
    >[/color]
    $result=xslt_pr ocess($processo r,'xsl/curriculum.xml' ,'xsl/curriculum.xsl' );[color=blue]
    > if (!$result) {
    > echo xslt_error($pro cessor);
    > }
    > else {echo $result;}
    >
    > xslt_free($proc essor);
    > ?>
    > ..where files are under c:\PHP directory!
    >
    > but this don't work:
    > <?php
    > $processor=xslt _create();
    > $path=dirname(_ _FILE__);
    > $tree="{$path}/xml/curriculum.xml" ;[/color]


    Why the {$path} ?
    I've not seen that before, how about just putting "$path/xml..." ?

    Kind Regards,

    --
    Ian P. Christian

    Comment

    • Simone

      #3
      Re: Sablotron

      >[color=blue]
      > Why the {$path} ?[/color]

      with '{' and '}' you can put a variable into a quoted string!

      look and try this example (PHP don't undersand wath's your variables):
      <?php
      $myname="simone ";
      echo "$mynameis my name <br>";
      echo "$myname is my name <br>";
      ?>
      ....and
      <?php
      $myname="simone ";
      echo "{$myname}i s my name <br>";
      ?>


      infact in this way:
      <?php
      $processor=xslt _create();
      $tree=dirname(_ _FILE__)."/xml/curriculum.xml" ;
      $transform=dirn ame(__FILE__)."/xml/curriculum.xsl" ;
      $result=xslt_pr ocess($processo r,$tree,$transf orm);
      if (!$result) {
      echo xslt_error($pro cessor);
      }
      else {echo $result;}

      xslt_free($proc essor);
      ?>
      Sablotron don't work !

      Simone




      Comment

      • Phil Roberts

        #4
        Re: Sablotron

        With total disregard for any kind of safety measures "Simone"
        <simoneNOSPAMva lenti@libero.it > leapt forth and uttered:
        [color=blue]
        > with '{' and '}' you can put a variable into a quoted string!
        >[/color]

        But you can do that with double-quoted strings anyway....

        --
        There is no signature.....

        Comment

        • Ian P. Christian

          #5
          Re: Sablotron

          Phil Roberts wrote:
          [color=blue]
          > With total disregard for any kind of safety measures "Simone"
          > <simoneNOSPAMva lenti@libero.it > leapt forth and uttered:
          >[color=green]
          >> with '{' and '}' you can put a variable into a quoted string!
          >>[/color]
          >
          > But you can do that with double-quoted strings anyway....
          >[/color]

          I Was being rather blonde when I questioned this one ;)

          $string = 'moo';
          echo "this is a $string"; // will work
          echo "this is a $stringwith text right after it"; // won't work
          echo "this is a {$string}with text right after it"; // will work

          Kind Regards,
          --
          Ian P. Christian

          Comment

          Working...