Connecting Tech Pros Worldwide Forums | Help | Site Map

Sablotron

Simone
Guest
 
Posts: n/a
#1: Jul 17 '05
this (my) script i's ok:
<?php
$processor=xslt_create();
$result=xslt_process($processor,'xsl/curriculum.xml','xsl/curriculum.xsl');
if (!$result) {
echo xslt_error($processor);
}
else {echo $result;}

xslt_free($processor);
?>
...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="{$path}/xml/curriculum.xsl";
$result=xslt_process($processor,$tree,$transform);
if (!$result) {
echo xslt_error($processor);
}
else {echo $result;}

xslt_free($processor);
?>
....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\curriculum-sablotron.php
on line 17 (--> $result=xslt_process($processor,$tree,$transform); )

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
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Sablotron


Simone wrote:
[color=blue]
> this (my) script i's ok:
> <?php
> $processor=xslt_create();
>[/color]
$result=xslt_process($processor,'xsl/curriculum.xml','xsl/curriculum.xsl');[color=blue]
> if (!$result) {
> echo xslt_error($processor);
> }
> else {echo $result;}
>
> xslt_free($processor);
> ?>
> ..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
Simone
Guest
 
Posts: n/a
#3: Jul 17 '05

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}is my name <br>";
?>


infact in this way:
<?php
$processor=xslt_create();
$tree=dirname(__FILE__)."/xml/curriculum.xml";
$transform=dirname(__FILE__)."/xml/curriculum.xsl";
$result=xslt_process($processor,$tree,$transform);
if (!$result) {
echo xslt_error($processor);
}
else {echo $result;}

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

Simone




Phil Roberts
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Sablotron


With total disregard for any kind of safety measures "Simone"
<simoneNOSPAMvalenti@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.....
Ian P. Christian
Guest
 
Posts: n/a
#5: Jul 17 '05

re: Sablotron


Phil Roberts wrote:
[color=blue]
> With total disregard for any kind of safety measures "Simone"
> <simoneNOSPAMvalenti@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
Closed Thread