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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xslt coding error

Status
Not open for further replies.

dazza12345

Programmer
Nov 25, 2005
35
GB
Hi all, any idea why the following xslt file will be causing the following error:

Warning: Sablotron error on line 1: XML parser error 2: syntax error in /home/fhlinux203/b/bewisebets.co.uk/user/htdocs/bewisepoker/2/example1.php on line 7
The XSLT processor failed [2]: XML parser error 2: syntax error

example1.php
Code:
<?php 
  // Create a XSLT Processor 
  // "$xsltproc" is the XSLT processor resource. 
  $xsltproc = xslt_create(); 

  // Processing the two files 
  $result = xslt_process( $xsltproc, '[URL unfurl="true"]http://www.pacificpoker.com/PokerTourInfo',[/URL] 'example.xslt' ); 

  // If we have a result then display the contents? 
  // If not then die and display the error information 
  if( $result ) { 
    echo "$result"; 
  } else { 
    die( sprintf( 
      "The XSLT processor failed [%d]: %s", 
      xslt_errno( $xsltproc ), 
      xslt_error( $xsltproc ) ) 
    ); 
  } 

  // Free up the XSLT Processor 
  xslt_free( $xsltproc ); 
?>
example.xslt
Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
  <xsl:output method="html" version="1.0" indent="yes"/>
  <xsl:param name="date" select="2006"/>
  <xsl:template match="/Tournament">
    <html>
      <head>
        <title>Tournoment Details</title>
      </head>
      <body>
        <table>
          <tr>
            <td>Tournament ID:</td>
            <td><xsl:value-of select="Tournament-ID" /></td>
          </tr>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
Cheers
 
Changing
Code:
  <xsl:template match="/Tournament">
to
Code:
  <xsl:template match="Tournament">
should get you started, though the results will most likely not be quite what you expect.

You might want to consider having your template match "/" then doing an xsl:for-each select="Tournament" to populate your table.

Tom Morrison
 
You would generate multiple unwanted html-head-title-body-table tags. Isolate them out. Try something like this to start with.
[tt]
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:eek:utput method="html" version="1.0" indent="yes"/>
<xsl:param name="date" select="2006"/>
<xsl:template match="/">
<html>
<head>
<title>Tournoment Details</title>
</head>
<body>
<table>
<xsl:apply-templates select="//Tournament" />
</table>
</body>
</html>
</xsl:template>
<xsl:template match="Tournament">
<tr>
<td>Tournament ID:</td>
<td><xsl:value-of select="Tournament-ID" /></td>
</tr>
</xsl:template>
</xsl:stylesheet>
[/tt]
The error message may or may not be xsl design related, just don't know and not in a position to offer anything.
 
Post your XML

Jon

"I don't regret this, but I both rue and lament it.
 
The problem is not with the transform here. I guess your code is not picking up the XML from the URL. Perhaps a security issue?

As far as the transform goes, do something similar to tsuji:
Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
  <xsl:template match="/">
    <html>
      <head>
        <title>Tournament Details</title>
      </head>
      <body>
        <table>
        <caption>Tournament Details</caption>
        <tr>
          <th>ID</th>
          <th>Name</th>
        </tr>
          <xsl:apply-templates select="PokerTournaments/Tournament" />
        </table>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="Tournament">
    <tr>
      <td><xsl:value-of select="Tournament-ID" /></td>
      <td><xsl:value-of select="Tournament-Name" /></td>
    </tr>
  </xsl:template>
</xsl:stylesheet>

Jon

"I don't regret this, but I both rue and lament it.
 
Any ideas on how I would go around testing if it is a security issue?
 
I am not sure that 'security issue' is the best term to use. Perhaps it would be better to use the term 'HTTP layer issue' which would include security issues, such as firewalls, etc.

I would use something like Ethereal to investigate what is happening at the HTTP layer. I certainly could fetch the XML document with a browser, save the document, and test your stylesheet as the basis for my initial reply.

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top