This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: "<xsl:if expr" doesnot work..Help!!
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] "<xsl:if expr" doesnot work..Help!!
- From: "Chris Bayes" <chris at bayes dot co dot uk>
- Date: Thu, 20 Sep 2001 12:18:51 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
I'll repeat what I said before
YOU DON'T NEED TO USE SCRIPT TO DO THIS!!!!!
Try
<xsl:if test=".[@someAttribute = 'Other']">
XML/XSL Portal
http://www.bayes.co.uk/xml
> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com] On Behalf Of
> Gurnandan Kaur
> Sent: 20 September 2001 09:58
> To: xsl-list@lists.mulberrytech.com
> Subject: RE: [xsl] "<xsl:if expr" doesnot work..Help!!
>
>
> Hi Chris,
>
> Thanks for the info.:) I realised that XSL was trying
> to assign value when I was calling that function, so I
> tried a different approach.
>
> Here is the xsl, with the problem solved. The xml is
> the same as from the previous mail I sent.
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
> <xsl:template match ="/">
> <form name="frmDetails" method="post"
> action="empEthnicSave.asp"> <table class="TableFullWidth"
> width="100%" cellspacing="10">
> <tr class="HeadRow" bgcolor="silver">
> <td align="center" colspan="2"><b>Ethnic
> Monitoring Questionnaire</b></td>
> </tr>
> <tr height="60">
> <td colspan="2">Which groups do you most identify
> with? Please tick only <b><u>ONE</u></b> box in
> <b>column A <u>and ONE</u></b> box in <b>column B</b>
> (The options are listed alphabetically). If you work
> in Northern Ireland, please answer the additional
> question in column A.</td>
> </tr>
> <tr>
> <td width="40%" valign="top">
> <table width="100%" cellpading="0"
> cellspacing="0">
> <tr>
> <td>
> <b>Column A</b>
> </td>
> </tr>
> <tr>
> <td>
> <xsl:for-each
> select="/ScreenPopulate/Nationalitys/Nationality">
>
> <xsl:value-of select="@alpha"/><input
> type="radio" name="RadioNation"><xsl:attribute
> name="value"><xsl:value-of
> select="./Key"/></xsl:attribute></input><xsl:value-of
> select="./Item"/> <br/>
> </xsl:for-each>
> <br/>
>
>       <input
> type="text" name="txtNation"/>
> </td>
> </tr>
> <tr height="60" valign="bottom" >
> <td>
> PLEASE ALSO
> ANSWER THE QUESTION BELOW <b>ONLY IF
> YOU WORK IN NORTHERN IRELAND:</b>
> </td>
> </tr>
> <tr>
> <td>
> Are you a
> member of the Irish Traveller
> Community?
> </td>
> </tr>
> <tr>
> <td>
> (T) <input
> type="radio" name="radioNorthern" value="Y">Yes</input>
> <br/>
> ( ) <input
> type="radio" name="radioNorthern" value="N">No</input>
> </td>
> </tr>
> </table>
> </td>
> <td width="60%" valign="top">
> <table width="100%" cellpading="0"
> cellspacing="0">
> <tr>
> <td>
> <b>Column B</b>
> </td>
> </tr>
> <xsl:for-each
> select="/ScreenPopulate/Backgrounds/Background">
> <xsl:choose>
> <xsl:when
> expr="testVal()">
> <tr>
> <td>
>
> <xsl:value-of select="@alpha"/><input type
> ="radio" name="radioBackground"><xsl:attribute
> name="value"><xsl:value-of
> select="./Key"/></xsl:attribute></input><xsl:value-of
> select="./Item"/><br/>
> </td>
> </tr>
> </xsl:when>
> <xsl:otherwise>
> <tr height="50">
> <td>
>
> <b><xsl:value-of select="@Group"/></b>
> </td>
> </tr>
> <tr>
> <td>
>
> <xsl:value-of select="@alpha"/><input type
> ="radio" name="radioBackground"><xsl:attribute
> name="value"><xsl:value-of
> select="./Key"/></xsl:attribute></input><xsl:value-of
> select="./Item"/><br/>
> </td>
> </tr>
> </xsl:otherwise>
> </xsl:choose>
> <xsl:if expr="BoolDisplay()">
> <tr>
>
> <td><input type="text"><xsl:attribute
> name="name">txtName</xsl:attribute></input></td>
> </tr>
> </xsl:if>
> </xsl:for-each>
> </table>
> </td>
> </tr>
> </table>
> <br/>
> <input type="submit" name="btnSubmit" value="Save
> Details"/>
> </form>
> </xsl:template>
> <xsl:script><![CDATA[
> strVal="aa"
> iCnt=0
> function testVal(attVal){
> attVal = this.attributes.item(0).text
> if (strVal == attVal ){
> return true;
> }
> else{
> strVal= attVal ;
> return false;
> }
> }
>
> function BoolDisplay()
> {
> ItemVal = this.selectNodes("Item").item(0).text
> ItemVal = ItemVal.substring(0,5)
> if (ItemVal=="Other")
> {
> return true;
> }
> else
> {
> return false;
> }
> iCnt = iCnt + 1
> }
> //]]></xsl:script>
> </xsl:stylesheet>
>
> Cheers!!
> --- Chris Bayes <chris@Bayes.co.uk> wrote: > It looks
> to me as if you cannot assign to function
> > result ;-)
> > Anyway you don't need script to do that. Why not
> > just do <xsl:if
> > test="@someatt = 'aa'>
> >
> > XML/XSL Portal
> > http://www.bayes.co.uk/xml
> >
> >
> > > -----Original Message-----
> > > From: owner-xsl-list@lists.mulberrytech.com
> > > [mailto:owner-xsl-list@lists.mulberrytech.com] On
> > Behalf Of
> > > Gurnandan Kaur
> > > Sent: 20 September 2001 08:16
> > > To: xsl-list@lists.mulberrytech.com
> > > Subject: [xsl] "<xsl:if expr" doesnot work..Help!!
> > >
> > >
> > > Hi
> > >
> > > I have a problem...I am creating a xsl file, in
> > which
> > > I am using xsl:script to get back a value
> > depending on
> > > the node matching. The xsl:eval function gets me
> > the
> > > right result, but when I use it in xsl:if expr, it
> > > says, "cannot assign to function result"..Here is
> > the
> > > xml and xsl please help..
> > >
> > > Thanks in advance
> > >
> > >
> > > XML:
> > > <!-- edited with XML Spy v3.5 NT
> > > (http://www.xmlspy.com) by () -->
> > > <?xml-stylesheet type="text/xsl"
> > >
> > href="D:\Inetpub\wwwroot\AHWRework\Ethnic\new.xsl"?>
> > > <ScreenPopulate>
> > > <Nationalitys>
> > > <Nationality alpha="(A)">
> > >
> > > <Key>{11277AE8-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>British or Mixed British</Item>
> > > </Nationality>
> > > <Nationality alpha="(B)">
> > >
> > > <Key>{11277AEA-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>English</Item>
> > > </Nationality>
> > > <Nationality alpha="(C)">
> > >
> > > <Key>{11277AEB-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Irish</Item>
> > > </Nationality>
> > > <Nationality alpha="(D)">
> > >
> > > <Key>{11277AEC-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Scottish</Item>
> > > </Nationality>
> > > <Nationality alpha="(E)">
> > >
> > > <Key>{11277AED-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Welsh</Item>
> > > </Nationality>
> > > <Nationality alpha="(F)">
> > >
> > > <Key>{11277AEE-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Other (specify if you wish)</Item>
> > > </Nationality>
> > > <Nationality>
> > >
> > > <Key>{7FB1E1A2-A856-11D5-A1A9-000347240DC9}</Key>
> > > <Item>No Reply</Item>
> > > </Nationality>
> > > </Nationalitys>
> > > <Backgrounds>
> > > <Background Group="Asian" alpha="(A)">
> > >
> > > <Key>{11277AEF-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Bangladeshi</Item>
> > > </Background>
> > > <Background Group="Asian" alpha="(B)">
> > >
> > > <Key>{11277AF0-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Indian</Item>
> > > </Background>
> > > <Background Group="Asian" alpha="(C)">
> > > <Key>{11277AF
> > > 1-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Pakistani</Item>
> > > </Background>
> > > <Background Group="Asian" alpha="(D)">
> > >
> > > <Key>{11277AF2-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Other (specify if you wish)</Item>
> > > </Background>
> > > <Background Group="Black" alpha="(E)">
> > >
> > > <Key>{11277AF3-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>African</Item>
> > > </Background>
> > > <Background Group="Black" alpha="(F)">
> > >
> > > <Key>{11277AF4-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Caribbean</Item>
> > > </Background>
> > > <Background Group="Black" alpha="(G)">
> > >
> > > <Key>{11277AF5-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Other (specify if you wish)</Item>
> > > </Background>
> > > <Background Group="Chinese" alpha="(H)">
> > >
> > > <Key>{11277AF6-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Chinese (specify if you wish</Item>
> > > </Background>
> > > <Background Group="Mixed Ethnic Background"
> > > alpha="(I)">
> > >
> > > <Key>{11277AF7-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Asian and White</Item>
> > > </Background>
> > > <Background Group="Mixed Ethnic Background"
> > > alpha="(J)">
> > >
> > > <Key>{11277AF8-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Black African and White</Item>
> > > </Background>
> > > <Background Group="Mixed Ethnic Background"
> > > alpha="(K)">
> > > <Key>{11277AF9-6967-11D5-A1
> > > 90-000347240DC9}</Key>
> > > <Item>Black Caribbean and White</Item>
> > > </Background>
> > > <Background Group="Mixed Ethnic Background"
> > > alpha="(L)">
> > >
> > > <Key>{11277AFA-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Other (specify if you wish)</Item>
> > > </Background>
> > > <Background Group="White" alpha="(M)">
> > >
> > > <Key>{11277AFB-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>White (specify if you wish)</Item>
> > > </Background>
> > > <Background Group="Other Ethnic Background"
> > > alpha="(N)">
> > >
> > > <Key>{11277AFC-6967-11D5-A190-000347240DC9}</Key>
> > > <Item>Other (specify if you wish)</Item>
> > > </Background>
> > > <Background Group="">
> > >
> > > <Key>{7FB1E1A1-A856-11D5-A1A9-000347240DC9}</Key>
> > > <Item>No Reply</Item>
> > > </Background>
> > > </Backgrounds>
> > > </ScreenPopulate>
> > >
> > > XSL:
> > > <?xml version="1.0" encoding="ISO-8859-1"?>
> > > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/TR/WD-xsl">
> > > <xsl:template match ="/">
> > > <html>
> > > <head>
> > >
> > > <title>Ethnic Origin</title>
> > > </head>
> > > <body>
> > > <table class="TableFullWidth" width="100%">
> > > <tr class="HeadRow" bgcolor="silver">
> > > <td align="center" colspan="2"><b>Ethnic
> > > Monitoring Questionnaire</b></td>
> > > </tr>
> > > <tr height="60">
> > > <td colspan="2">Which groups do you most
> > identify
> > > with? Please tick only <b><u>ONE</u></b> box in
> > > <b>column A <u>and ONE</u></b> box in <b>column
> > B</b>
> > > (The options are listed alphabetically). If you
> > work
> > > in Northern Ireland, please answer the additional
> > > question in column A.</td>
> > > </tr>
> > > <tr>
> > > <td width="40%" valign="top">
> > > <table width="100%" cellpading="0"
> > > cellspacing="0">
> > > <tr>
> > > <td>
> > > <b>Column A</b>
> > > </td>
> > > </tr>
> > > <tr>
> >
> === message truncated ===
>
> ____________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
> or your free @yahoo.ie address at http://mail.yahoo.ie
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list