homepage Welcome to WebmasterWorld Guest from 54.227.146.68
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

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




msg:1292605
 9:13 pm on Sep 15, 2003 (gmt 0)

Warning: Sablotron error on line 4: XML parser error 4: not well-formed (invalid token) in c:\dir1\dir2\xml.php on line 7

PHP CODE:
1: <?php
2:
3: // Allocate a new XSLT processor
4: $xh = xslt_create();
5:
6: // Process the document, returning the result into the $result variable
7: $result = xslt_process
($xh, 'file://C:/dir1/dir2/simple.xml', 'file://C:/dir1/dir2/simple.xsl');
8:
9: xslt_free($xh);
10:
11:?>

XML:
<?xml version="1.0"?>
<simple>
<node>1</node>
<node>2</node>
</simple>

XSL:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<textarea>
<xsl:value-of select="/"/>
</textarea>
</xsl:template>
</xsl:stylesheet>

I've tried everything - any idea what's wrong? The path's are definitely accurate (if I change them I get a different error saying could not open file)... I'm totally baffled :(

 

joshie76




msg:1292606
 9:22 pm on Sep 15, 2003 (gmt 0)

I've also tried it without the <?xml version="1.0"?> to no avail...

joshie76




msg:1292607
 12:33 pm on Sep 19, 2003 (gmt 0)

Nobody any idea on this one then? I'm still totally flumoxed. :(

Alternative Future




msg:1292608
 12:40 pm on Sep 19, 2003 (gmt 0)

Stab in the dark>

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<textarea>
<xsl:value-of select="
node"/>
</textarea>
</xsl:template>
</xsl:stylesheet>

When I work with xsl-fo I use absolute naming for the element name where the xsl:template match="/" matches
simple and the child node is this case is called node

-gs

joshie76




msg:1292609
 1:18 pm on Sep 19, 2003 (gmt 0)

but nonetheless the example given is valid XSL(T), no?

Can't see that being it but I'll be sure to try when I get home.

Alternative Future




msg:1292610
 1:26 pm on Sep 19, 2003 (gmt 0)

Your probably right joshie76,

Am not fluent in PHP so the problem probably lies there, as for the xsl and xml all looks fine, just that am more used to the absolute naming of the node set.

I would be interested to find out the problem when you get to the bottom of it!

Where is the example located (might have a quick try)?

-gs

joshie76




msg:1292611
 1:35 pm on Sep 19, 2003 (gmt 0)

Thanks AF, I'm running it locally at home at the mo' but not much to see, other than that error message, anyway...

I'll be sure to let you know if I crack it - my gut feeling is that something is wrong with php/sablotron on my machine but all this *nix stuff is my achilles heel.

J

mogwai




msg:1292612
 1:37 pm on Sep 19, 2003 (gmt 0)

Hi,

I had a few spare minutes so I ran the code you provided in your first post. It works fine for me, prints the value of the first node in the text area.

Are you sure that you are actually using this xsl? In my limited experience of Sablotron it generally throws up these errors when there is non valid xml in the xsl file. I don't mean to sound patronising saying that, on many occasions I've been ready to throw my machine out of the window simply because I was using the wrong (un-modified) xsl file :)

Also, to print the value of both nodes you would use:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<textarea>
<xsl:for-each select="//node">
<xsl:value-of select="."/>
</xsl:for-each>
</textarea>
</xsl:template>
</xsl:stylesheet>

coopster




msg:1292613
 1:42 pm on Sep 19, 2003 (gmt 0)

<edit>mogwai got it in there: double-check the files being used<edited>

Which version of PHP are you running?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved