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 December 31st, 2005, 01:39 PM
Registered User
 
Join Date: Dec 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Simple (for most) Variable Question

Hi all,

I am doing something that I'm sure is simple but I just can't seem to make it work.

I have a selection of elements called command. One of these is
<command position="236">1B286C02003400</command>

My stylesheet template that I want to apply to this element looks something like this:

   <xso:template match="command[starts-with(.,'1B286C')]">
      <command>
         <xso:variable name="position" select="@position"/>
         <position>
            <xso:value-of select="$position"/>
         </position>
         <initialCode>1B286C</initialCode>
         <name>Set Paper Loading</name>
         <xso:variable name="command" select="."/>
          <xso:value-of select="$command"></xso:value-of>
          <xso:variable name="A" select="substring($command, 11,2)"/>

          <xso:if test="starts-with($A,'34')">
               <xso:value-of select="Sets a printer model ID and specifies the media source to be the automatic sheet feeder"/>
         </xso:if>
...

The command value is picked up correctly but I can't for the life of me get the test to work. I can't even get it to work if I set the variable A to be 34. The substring function is picking out 34 so I don't understand why my test doesn't work.
I've tried things like

<xso:if test="$A='34')"> and other combinations of brackets etc.
but still no luck.
Any help or thoughts would be gratefully received.

Thanks and happy new year!!
Clare

 
Old December 31st, 2005, 01:59 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The value of the select attribute of xsl:value-of must be an XPath expression. Try replacing

<xso:value-of select="Sets a ... feeder"/>

by

<xso:value-of select="'Sets a ... feeder'"/>

But I would have expected your existing code to give a sensible error message making this clear.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old December 31st, 2005, 08:42 PM
Registered User
 
Join Date: Dec 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, my fault for not being clear. It's the test that is always false regardless of what I put it.






Similar Threads
Thread Thread Starter Forum Replies Last Post
very simple question rogdawg Visual Studio 2005 2 January 14th, 2008 04:03 PM
Very simple variable assignment question gegonut ADO.NET 2 May 3rd, 2007 11:34 AM
Simple Question ironchef Spring 2 April 30th, 2007 09:32 AM
Simple Question ironchef Java GUI 0 September 14th, 2006 04:56 PM
Simple question maximus101 Classic ASP Basics 2 October 18th, 2005 10:22 PM





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