Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 7th, 2015, 12:26 PM
Authorized User
 
Join Date: Mar 2007
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default Why it doesn't work?

What am I not seeing here?

I am used to declare and use variables in XSLT all the time but for any reason this simple thing is not working and I am not managing to see what is wrong with it:

Code:
<?xml version="1.0" encoding="UTF-8" ?>
<package debug="false">
  <PackageTransform>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="http://www.DNSF2.com">
      <xsl:output method="html" omit-xml-declaration="yes" />
      <xsl:template match="/">
        Testing...<br/>
        <xsl:variable name="foo" select="foobah" />
        My foo value is = <xsl:value-of select="$foo" />
      </xsl:template>
    </xsl:stylesheet>
  </PackageTransform>
</package>
 
Old January 7th, 2015, 12:41 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Does your input XML have an element called <foobah>?
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old January 7th, 2015, 01:34 PM
Authorized User
 
Join Date: Mar 2007
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Ouch, never mind, my bad.



I supposed to do it instead:

Code:
<xsl:variable name="foo" >foobah</xsl:variable>
I stayed the whole morning over that, and simply didn't see what I was doing.


Last edited by yankleber; January 7th, 2015 at 01:40 PM..
 
Old January 8th, 2015, 05:56 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

What you were probably wanting to do was this:

Code:
<xsl:variable name="foo" select="'foobah'"/>
That creates a variable $foo and assigns it the string 'foobah'. What you has previously was missing the single quotes, so was looking for an element called <foobah> and taking its textual value.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
yankleber (January 8th, 2015)
 
Old January 8th, 2015, 08:36 AM
Authorized User
 
Join Date: Mar 2007
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Cool, yeah, that's exactly what I had in mind! Thank you again, Sam!






Similar Threads
Thread Thread Starter Forum Replies Last Post
SMS API does not work online but work fine offline. Tonik Beginning PHP 1 January 4th, 2013 08:30 AM
Chapter 1 Ctrl+F5 don't work, F5 does work? jimboak BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 7 June 29th, 2008 03:46 AM
Why Does This Work? Little Shell VB How-To 2 October 13th, 2006 05:26 PM
should this work? crmpicco Javascript How-To 1 January 18th, 2005 10:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.