Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLTProcessor - transformToXML only working on files

Status
Not open for further replies.

Teamgc

Programmer
Feb 15, 2006
37
IE
I'm new to XSLTProcessing in PHP and I have a very strange problem.

I am getting results back in XML format from a webservice. and when I load them into an XMLDoc and then try to transformToXML I get no results.

If I output the result I get from the webservice, copy and paste it into an XMLDoc and load that, the transformToXML works perfectly.

any idea what I am doing wrong?

Code:
$xmlDoc = new DOMDocument();
//$xmlDoc->load("properties.xml");
$xmlDoc->loadXML($xml);

$xsl = new DomDocument;
$xsl->load("property1.xsl");

$proc = new xsltprocessor;
$proc->importStyleSheet($xsl);

try {
	$result = $proc->transformToXML($xmlDoc); 
 } catch (Exception $ex) {
    throw new apException("Unable to transform XSL");
  }
  
echo $result;

and my XSL is

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]

<xsl:template match="/">
    <xsl:for-each select="newdataset/table">    
	<div class="redheader">
		<a href="#">
			<xsl:value-of select="displayaddress"/> - <xsl:value-of select="shortdescription"/>
		</a>
	</div>
	<div class="subcontent">
		
	
		<table border="0">
		<tr>
		<td rowspan="4">
	        <xsl:value-of select="imagelink"/>
		</td>     
		<td>&#160;</td>		
		<td><strong>Address:</strong> <xsl:value-of select="addr1"/> </td>
		</tr>
    <tr>
	<td>&#160;</td>
	<td><strong>Reference Number:</strong><xsl:value-of select="pkid"/></td> 
     </tr>
     <tr>
	<td>&#160;</td>
	<td><strong>Soverom:</strong> <xsl:value-of select="rooms"/></td>
     </tr>
     <tr>
	<td>&#160;</td>
      <td><strong><xsl:value-of select="description1"/></strong></td>
     </tr>  
    </table>
    
    </div>
    
    </xsl:for-each>
 </xsl:template>

</xsl:stylesheet>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top