[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: roblems with passing variables from PHP to XSLT

Subject: Re: roblems with passing variables from PHP to XSLT
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 6 Jun 2006 14:00:06 +0100
php code in xsl
You want to make code a parameter to the stylesheet

  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0" xmlns:php="http://php.net/xsl">

  <xsl:output method="html"/>

  <xsl:param name="code" select="'PEN'"/>

then you can change the value from its default 'PEN' when you call XSLT
(the details depend on the API you are using, sorry I can't help with
php, but google or the docs will no doubt say how to initialise a
stylesheet parameter, once you have one declared).

then in an ideal world you would just replace  'PEN' in your code with
$code and it would all work:

<xsl:template match="IATA[@code=$code]/ProductItem">.....</xsl:template>
<xsl:template match="IATA[@code!=$code]/ProductItem"></xsl:template>
Beware that those two tests are not mutually exclusive, you probably
want
<xsl:template match="IATA[not(@code=$code)]/ProductItem"></xsl:template>
for the second one

However unfortuantely there is a restriction in XSLT1 (which you are
using) that you can not use variables in match patterns. In XSLT2 this
restriction is gone, but in XSLT1 you have to re-write it as


<xsl:template match="IATA/ProductItem">
<xsl:if test="@code=$code">.....</xsl:if></xsl:template>
</xsl:template>

  <xsl:value-of
  select="ProductItemDetail/ProductText"
  disable-output-escaping="yes"/></p>

Don't use  disable-output-escaping unless you are sure you really need
it (and even then don't use it unless your really can't avoid it).



David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.