Forum Moderators: coopster
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 :(
<?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
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
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>