Re: XSLT issue
| From: | T.Lensselink | Date: | Wed, 03 May 2006 12:04:59 +0000 |
| Subject: | Re: XSLT issue | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-235354@lists.php.net to get a copy of this message | ||
> Thank you very much for your generous and prompt help. The stylesheet I am
> now using looks like this:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:template match="/xmlfeed">
>
> <html>
> <head>
> <title>Results of XSL transformation</title>
> <style type="text/css" media="Screen">
> @import url(games_output.css);
> </style>
> <script type="text/javascript"
> src="master.js"></script>
> <script type="text/javascript"
> src="scroller.js"></script>
> </head>
> <body>
> <div id="top3">
> <xsl:call-template name="results"/>
> </div>
> </body>
> </html>
> </xsl:template>
>
> <xsl:template name="results">
> <xsl:for-each select="tournament">
> <xsl:if test="not(position() = 4)">
> <table id="top3table" cellspacing="0">
> <tr
> class="odd"><th>Tid</th><td><xsl:value-of select="tid"
> /></td></tr>
> <tr><th>Type</th><td><xsl:value-of
> select="name"/></td></tr>
> <tr
> class="odd"><th>Game</th><td><xsl:value-of
> select="game" /></td></tr>
> <tr><th>Buy-In</th><td>$<xsl:value-of
> select="buyin"/></td></tr>
> <tr
>
> class="odd"><th>Status</th><td><xsl:value-ofselect="state"
> /></td></tr>
> <tr><th>Players</th><td><xsl:value-of
> select="players"/></td></tr>
> <tr class="odd"><th>Date /
> Time</th><td><xsl:value-of
> select="starttime" /></td></tr>
> </table>
> <hr />
> </xsl:if>
> </xsl:for-each>
> </xsl:template>
> </xsl:stylesheet>
>
> ...but I get this:
>
> *Warning*: Sablotron error on line 31: XML parser error 4: not well-formed
> (invalid token) in
> */home/stevemas/public_html/dg/xslt/xslt_processor.php*on line
> *14
>
> ...I have included your positioning syntax and am using this method, could
> you point out where I am going wrong (as I use the Sablotron processor I
> am
> not using those DOM functions). Many thanks.
> *
> On 03/05/06, T.Lensselink <admin@ensifex.nl> wrote:
>>
>> > And I used this:
>> >
>> > <xsl:template name="results">
>> >
>> > <xsl:for-each select="tournament">
>> > <xsl:if test="position() < 4">
>> > <table id="top3table" cellspacing="0">
>> > <tr
>> > class="odd"><th>Tid</th><td><xsl:value-of
>> > select="tid" /></td></tr>
>> > <tr><th>Type</th><td><xsl:value-of
>> > select="name"
>> > /></td></tr>
>> > <tr
>> > class="odd"><th>Game</th><td><xsl:value-of
>> > select="game" /></td></tr>
>> > <tr><th>Buy-In</th><td>$<xsl:value-of
>> select="buyin"
>> > /></td></tr>
>> > <tr
>> > class="odd"><th>Status</th><td><xsl:value-of
>> > select="state" /></td></tr>
>> > <tr><th>Players</th><td><xsl:value-of
>> select="players"
>> > /></td></tr>
>> > <tr class="odd"><th>Date /
>> Time</th><td><xsl:value-of
>> > select="starttime" /></td></tr>
>> > </table>
>> > <hr />
>> > </xsl:if>
>> > </xsl:for-each>
>> > </xsl:template>
>> >
>> > On 03/05/06, Dave Goodchild <buddhamagnet@gmail.com> wrote:
>> >>
>> >> Thanks for our help. Tried both methods and I get this:
>> >>
>> >> *Warning*: Sablotron error on line 31: XML parser error 4: not
>> >> well-formed
>> >> (invalid token) in
>> >> */home/stevemas/public_html/dg/xslt/xslt_processor.php*on line
>> >> *14*
>> >>
>> >>
>> >> On 03/05/06, T.Lensselink <admin@ensifex.nl> wrote:
>> >> >
>> >> > > Hi all, maybe slightly off list but I AM using php and Sablotron
>> to
>> >> > > generate
>> >> > > xslt.
>> >> > >
>> >> > > I have a live poker games feed that takes the following format:
>> >> > >
>> >> > > <?xml version=" 1.0"
>> >> > > encoding="utf-8"?><xmlfeed>
>> >> > > <tournament>
>> >> > > <tid>10035522</tid>
>> >> > > <name>Texas Holdem</name>
>> >> > > <game>Texas Holdem Poker</game>
>> >> > > <buyin>5</buyin>
>> >> > > <entryfee>0.5</entryfee>
>> >> > > <currency>USD</currency>
>> >> > > <state>Running</state>
>> >> > > <players>110</players>
>> >> > > <blindstructure>Normal NL 1</blindstructure>
>> >> > > <type>Regular</type>
>> >> > > <limit>No Limit</limit>
>> >> > > <starttime>2006-04-24T07:00:00</starttime>
>> >> > > </tournament>
>> >> > >
>> >> > > <tournament>
>> >> > > <tid>10035126</tid>
>> >> > > <name>Texas Holdem</name>
>> >> > > <game>Texas Holdem Poker</game>
>> >> > > <buyin>20</buyin>
>> >> > > <entryfee>2</entryfee>
>> >> > > <currency>USD</currency>
>> >> > > <state>Running</state>
>> >> > > <players>79</players>
>> >> > > <blindstructure>Normal NL 1</blindstructure>
>> >> > > <type>Regular</type>
>> >> > > <limit>No Limit</limit>
>> >> > > <starttime>2006-04-24T08:00:00</starttime>
>> >> > > </tournament>
>> >> > >
>> >> > > etc etc
>> >> > >
>> >> > > and all I want to do is output the first THREE tournament
>> elements
>> >> and
>> >> > no
>> >> > > more. I realise XSLT has no general repetition mechanism but does
>> >> > anyone
>> >> > > know how I would do this? Thanks in advance, and to my Dutch
>> friend,
>> >> I
>> >> >
>> >> > > meant
>> >> > > it when I said lovely baby.
>> >> > >
>> >> > > --
>> >> > > http://www.web-buddha.co.uk
>> >> > >
>> >> > > dynamic web programming from Reigate, Surrey UK (php, mysql,
>> xhtml,
>> >> > css)
>> >> > >
>> >> > > look out for project karma, our new venture, coming soon!
>> >> > >
>> >> >
>> >> > Not tested but have no resources for it right now...
>> >> >
>> >> > <xsl:for-each select="tournament/[position() < 4]">
>> >> > <xsl:value-of select="tid"/>
>> >> > </xsl:for-each>
>> >> >
>> >> > or:
>> >> >
>> >> > <xsl:for-each select="tournament/">
>> >> > <xsl:if test="position() < 4">
>> >> > <xsl:value-of select="tid"/>
>> >> > </xsl:if>
>> >> > </xsl:for-each>
>> >> >
>> >> > --
>> >> > PHP General Mailing List (http://www.php.net/)
>> >> > To unsubscribe, visit:
>> >> > http://www.php.net/unsub.php
>> >> >
>> >> >
>> >>
>> >>
>> >> --
>> >>
>> >> http://www.web-buddha.co.uk
>> >>
>> >> dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml,
>> css)
>> >>
>> >> look out for project karma, our new venture, coming soon!
>> >>
>> >
>> >
>> >
>> > --
>> > http://www.web-buddha.co.uk
>> >
>> > dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml,
>> css)
>> >
>> > look out for project karma, our new venture, coming soon!
>> >
>>
>>
>> Sorry for the bad code... Made a small test scenario..
>>
>> php
>> <?php
>> $xml = '<?xml version="1.0" encoding="utf-8"?>
>> <xmlfeed>
>> <tournament>
>> <tid>10035522</tid>
>> <name>Texas Holdem</name>
>> <game>Texas Holdem Poker</game>
>> <buyin>5</buyin>
>> <entryfee>0.5</entryfee>
>> <currency>USD</currency>
>> <state>Running</state>
>> <players>110</players>
>> <blindstructure>Normal NL 1</blindstructure>
>> <type>Regular</type>
>> <limit>No Limit</limit>
>> <starttime>2006-04-24T07:00:00</starttime>
>> </tournament>
>>
>> <tournament>
>> <tid>10035126</tid>
>> <name>Texas Holdem</name>
>> <game>Texas Holdem Poker</game>
>> <buyin>20</buyin>
>> <entryfee>2</entryfee>
>> <currency>USD</currency>
>> <state>Running</state>
>> <players>79</players>
>> <blindstructure>Normal NL 1</blindstructure>
>> <type>Regular</type>
>> <limit>No Limit</limit>
>> <starttime>2006-04-24T08:00:00</starttime>
>> </tournament>
>> </xmlfeed>';
>>
>> $domXmlObj = domxml_open_mem($xml);
>> $domXsltObj = domxml_xslt_stylesheet_file('./test.xsl');
>> $domTranObj = $domXsltObj->process($domXmlObj);
>>
>> echo $domXsltObj->result_dump_mem($domTranObj);
>> ?>
>>
>> xsl:
>> <?xml version="1.0" encoding="ISO-8859-1"?>
>> <xsl:stylesheet version="1.0"
>>
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>> <xsl:template match="/">
>>
>> <xsl:for-each select="xmlfeed/tournament">
>> <xsl:if test="not(position() = 4)">
>> <table id="top3table" cellspacing="0">
>> <tr
>> class="odd"><th>Tid</th><td><xsl:value-of
>> select="tid" /></td></tr>
>> <tr><th>Type</th><td><xsl:value-of
>> select="name"
>> /></td></tr>
>> <tr
>> class="odd"><th>Game</th><td><xsl:value-of
>> select="game" /></td></tr>
>> <tr><th>Buy-In</th><td>$<xsl:value-of
>> select="buyin"
>> /></td></tr>
>> <tr
>> class="odd"><th>Status</th><td><xsl:value-of
>> select="state" /></td></tr>
>> <tr><th>Players</th><td><xsl:value-of
>> select="players"
>> /></td></tr>
>> <tr class="odd"><th>Date /
>> Time</th><td><xsl:value-of
>> select="starttime" /></td></tr>
>> </table>
>> <hr />
>> </xsl:if>
>> </xsl:for-each>
>> </xsl:template>
>> </xsl:stylesheet>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> http://www.web-buddha.co.uk
>
> dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)
>
> look out for project karma, our new venture, coming soon!
>
Maybe try
<xsl:value-of select="state" />
instead of:
<xsl:value-ofselect="state" />