Welcome to WebmasterWorld Guest from 50.17.5.36

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Sablotron Error

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

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 10, 2001
posts:793
votes: 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 :(

9:22 pm on Sept 15, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 10, 2001
posts:793
votes: 0


I've also tried it without the <?xml version="1.0"?> to no avail...
12:33 pm on Sept 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 10, 2001
posts:793
votes: 0


Nobody any idea on this one then? I'm still totally flumoxed. :(
12:40 pm on Sept 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 22, 2003
posts:1022
votes: 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

1:18 pm on Sept 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 10, 2001
posts:793
votes: 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.

1:26 pm on Sept 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 22, 2003
posts:1022
votes: 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

1:35 pm on Sept 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 10, 2001
posts:793
votes: 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

1:37 pm on Sept 19, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 26, 2003
posts:50
votes: 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>

1:42 pm on Sept 19, 2003 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12533
votes: 0


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

Which version of PHP are you running?