[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: String comparisons fail unexpectedly: how can 'USA
----- Original Message ----- From: <TSchutzerWeissmann@xxxxxxxxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Wednesday, February 27, 2002 12:26 PM Subject: String comparisons fail unexpectedly: how can 'USA' not be 'USA'? > Dear list, > > this is very frustrating! I want to pull out lots of records from a data > source using a list. The data source has records that look like this: > <Billcode corp="EvilEmpire" country="USA"> > > and the list is an html table with rows like this: > > <tr><td>EvilEmpire</td><td>USA</td></tr> > > Initially I tried using a key with use="concat(@corp,'::',@country)" but no > joy, after a lot of trying things out very patiently or not so patiently I > tried this: hmmm, a key for sorting these values i suspect ? look at www.dpawson.co.uk XSL faq area on keys for this... > <xsl:value-of select="Billcode[2]/@country"/> > <xsl:value-of select="'USA'=Billcode[2]/@country"/> > u need to put the current node test first but in any event the following should be illustrative of how one would get the right test ( i've used a for-each, but of course u could use templates ) xsl file ---------------------------------------------- <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="root"> <xsl:for-each select="//Billcode"> <xsl:value-of select="@country='USA'"/> </xsl:for-each> </xsl:template> </xsl:stylesheet> xml file ---------------------------------------------------- <?xml version="1.0" ?> <root> <Billcode corp="EvilEmpire" country="USA"/> <Billcode corp="FunEmpire" country="UK"/> <Billcode corp="SunEmpire" country="BERMUDA"/> </root> > and got, to my surprise, "USAfalse". > > There must be something important I don't know about string comparisons! > > I've tried wrapping things in string( )s but to no avail. > Any help much appreciated, HTH, in the future i would include a slightly more defined example of 'what u want to do' maybe in the form of desired results, also pls quote your XSLT processor, cheers, jim fuller > Tom SW > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|