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 27th, 2006, 04:46 AM
Authorized User
 
Join Date: Jan 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RazoRmedia
Default missing attribute

Hello, wonder if you could help me with a slight problem:

heres a snippet of my XML:


<selection DMLTYPE="U" TABLEID="3575680.10" IDFOSELECTION="3575680.10" IDFOMARKET="146372.10" IDFOPARTICIPANT="305876.10" NAME="Mclachlan, Fraser" FULLNAME="Mclachlan, Fraser" IDFOBOLIFESTATE="N" IDSELECTIONSTATE="N" SHORTNAME="MCLACHLAN" ALTERNATIVENAME="MCLACHLAN" ISGPOPTIONON="0" ISRESERVE="0" HADVALUE="A" INTERNALORDER="3575680.10" CURRENTPRICEUP="50" CURRENTPRICEDOWN="1" DECIMALPRICE="51.00" PRICEHISTORY="80/1,50/1" />

<selection DMLTYPE="U" TABLEID="3575682.10" IDFOSELECTION="3575682.10" IDFOMARKET="146372.10" IDFOPARTICIPANT="305243.10" NAME="Rundle, Adam" FULLNAME="Rundle, Adam" IDFOBOLIFESTATE="N" IDSELECTIONSTATE="N" SHORTNAME="RUNDLE, A" ALTERNATIVENAME="RUNDLE, A" ISGPOPTIONON="0" ISRESERVE="0" HADVALUE="A" INTERNALORDER="3575682.10" CURRENTPRICEUP="20" CURRENTPRICEDOWN="1" DECIMALPRICE="21.00" PRICEHISTORY="50/1,20/1" />

<selection DMLTYPE="U" TABLEID="3575683.10" IDFOSELECTION="3575683.10" IDFOMARKET="146372.10" IDFOPARTICIPANT="290566.10" NAME="Uhlenbeek, Gus" FULLNAME="Uhlenbeek, Gus" IDFOBOLIFESTATE="N" IDSELECTIONSTATE="N" SHORTNAME="UHLENBEEK" ALTERNATIVENAME="UHLENBEEK" ISGPOPTIONON="0" ISRESERVE="0" HADVALUE="A" INTERNALORDER="3575683.10" CURRENTPRICEUP="40" CURRENTPRICEDOWN="1" DECIMALPRICE="41.00" PRICEHISTORY="40/1" />

<selection DMLTYPE="U" TABLEID="3575761.10" IDFOSELECTION="3575761.10" IDFOMARKET="146372.10" IDFOPARTICIPANT="1243918.10" NAME="Coke, Giles" FULLNAME="Coke, Giles" IDFOBOLIFESTATE="N" IDSELECTIONSTATE="N" SHORTNAME="Coke, Gil" ALTERNATIVENAME="Coke, Gil" ISGPOPTIONON="0" ISRESERVE="0" INTERNALORDER="3575674.35" CURRENTPRICEUP="22" CURRENTPRICEDOWN="1" DECIMALPRICE="23.00" PRICEHISTORY="22/1" />


Now as can be seen, there is not HADVALUE attribute for the last selection above, this happens occasionly with the XML feed I am receiving.


a snippet of code from my .xsl is posted below. I am merely trying to find out if the player (this is a football first goalscorer screen for a betting shop) is home or away and if neither, assign the class as HOMENAME.

<td align="left">
<xsl:attribute name="class">
   <xsl:if test="not(@HADVALUE)">HOMENAME</xsl:if>
   <xsl:if test="@HADVALUE='H'">HOMENAME</xsl:if>
   <xsl:if test="@HADVALUE='D'">DRAWNAME</xsl:if>
   <xsl:if test="@HADVALUE='A'">AWAYNAME</xsl:if>
</xsl:attribute>

this doesn't work, no class is being assigned to the player coke,giles. anyone got a solution to this as I have searched the forums but can't seem to find any info on missing attributes, only missing nodes.

Thanks in advance.


 
Old January 27th, 2006, 05:42 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your code looks correct to me. Which usually means the bug is in the part that you haven't shown us... Try to produce a complete but cut-down example that demonstrates the problem.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 27th, 2006, 08:03 AM
Authorized User
 
Join Date: Jan 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RazoRmedia
Default

You were right, I created a lite version and figured out my problem immediately.

I had a rogue if statement in there.

Cheers Michael.

 
Old January 27th, 2006, 08:18 AM
Authorized User
 
Join Date: Jan 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RazoRmedia
Default

on a related not, the reason I didn't see it is that I am using marrowsoft xselerator as my editor and the if statement was off the screen to the right.

whats everyone else use, I know your book suggests saxon but whats the pros and cons of peoples tools ?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace an attribute with another attribute georgemeng XSLT 8 June 10th, 2008 11:04 AM
Use xPath to test for an absent/missing attribute NitroxDM XSLT 3 June 13th, 2007 09:00 AM
missing attribute RazoRmedia XSLT 8 January 4th, 2006 02:12 PM
Access to attribute values from class of attribute jacob C# 1 October 28th, 2005 01:11 PM
get attribute value... clayman58 XSLT 1 August 9th, 2005 04:33 AM





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