You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Robinson Simon <Si...@newton.co.uk> on 2002/10/24 17:55:12 UTC

XSL:IF

I am trying to test the content of the Subject_Area element to see if it
contains the value 'Securities'. The idea being to pass in the name of an
Oracle entity and then show all the attributes for that entity. The line
concerned is

<xsl:if test="Subject_Area='Securities'"> ** The element does contain the
value concerned but is not generating the rest of the output as I would
expect. The portion of the XML I am testing is below.

Any help would be greatly appreciated.

Regards

Simon

<Name>Securities</Name>
<Definition>Securities group entity</Definition>

----------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="D:\_t2\XML\subjects.xsl"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="html" indent="yes"/>

<xsl:template match="* | / "/>

<xsl:template match="/">
<xsl:apply-templates select="ERwin4"/>
</xsl:template>
 
<xsl:template match="ERwin4">
<xsl:value-of select="@FileVersion"/>
<xsl:apply-templates select="Model"/>
</xsl:template>

<xsl:template match="Model">
<br></br>
<xsl:apply-templates select="Subject_Area_Groups"/>
</xsl:template>

<!-- <xsl:template match="/">
<xsl:apply-templates select="Subject_Area_Groups"/>
</xsl:template> -->

<xsl:template match="Subject_Area_Groups">
In the body
<xsl:apply-templates select="Subject_Area"/>
</xsl:template>

<xsl:template match="Subject_Area">

<xsl:if test="Subject_Area='Securities'">
<br></br>
<xsl:apply-templates select="Subject_AreaProps"/>
</xsl:if>

After the test
</xsl:template>

<xsl:template match="Subject_AreaProps">
<xsl:value-of select="Name"/>
<xsl:value-of select="Definition"/>
</xsl:template>

</xsl:stylesheet>

-----Original Message-----
From: Joseph Kesselman [mailto:keshlam@us.ibm.com]
Sent: 24 October 2002 16:57
To: 'xalan-j-users@xml.apache.org'
Subject: Re: checking for null


Try:    <xsl:if test="not($testlink)"> ?

______________________________________
Joe Kesselman  / IBM Research


The information contained in or attached to this message is confidential
and is solely for the use of the addressee.  If you are not the intended 
recipient please notify us immediately by return email to 
postmaster@newton.co.uk 
and delete the message from your system. Internet communications 
are not secure.The Newton group and other subsidiaries of 
Mellon Europe Ltd accepts no liability for changes to this
message after it was sent. Any views expressed by an individual in this 
email do not necessarily reflect the views of the group.  If you have 
any questions regarding the contents of this email please contact 
Information_Security@newton.co.uk

Re: XSL:IF

Posted by "Frank E. Weiss" <fr...@well.com>.
When you write <xsl:if test="Subject_Area='Securities'"> that is really a shorthand for <xsl:if
test="child::Subject_Area='Securities'">. Since this occurs in the template that matches the element Subject_Area, it is
looking for child nodes thereof. You probably need to write <xsl:if test="string(.)='Securities'"> or better yet <xsl:if
test="normalize-space(.)='Securities'">.

-- Frank Weiss

Robinson Simon wrote:

> I am trying to test the content of the Subject_Area element to see if it
> contains the value 'Securities'. The idea being to pass in the name of an
> Oracle entity and then show all the attributes for that entity. The line
> concerned is
>
> <xsl:if test="Subject_Area='Securities'"> ** The element does contain the
> value concerned but is not generating the rest of the output as I would
> expect. The portion of the XML I am testing is below.
>
> Any help would be greatly appreciated.
>
> Regards
>
> Simon
>
> <Name>Securities</Name>
> <Definition>Securities group entity</Definition>
>
> ----------------------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet type="text/xsl" href="D:\_t2\XML\subjects.xsl"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fo="http://www.w3.org/1999/XSL/Format">
> <xsl:output method="html" indent="yes"/>
>
> <xsl:template match="* | / "/>
>
> <xsl:template match="/">
> <xsl:apply-templates select="ERwin4"/>
> </xsl:template>
>
> <xsl:template match="ERwin4">
> <xsl:value-of select="@FileVersion"/>
> <xsl:apply-templates select="Model"/>
> </xsl:template>
>
> <xsl:template match="Model">
> <br></br>
> <xsl:apply-templates select="Subject_Area_Groups"/>
> </xsl:template>
>
> <!-- <xsl:template match="/">
> <xsl:apply-templates select="Subject_Area_Groups"/>
> </xsl:template> -->
>
> <xsl:template match="Subject_Area_Groups">
> In the body
> <xsl:apply-templates select="Subject_Area"/>
> </xsl:template>
>
> <xsl:template match="Subject_Area">
>
> <xsl:if test="Subject_Area='Securities'">
> <br></br>
> <xsl:apply-templates select="Subject_AreaProps"/>
> </xsl:if>
>
> After the test
> </xsl:template>
>
> <xsl:template match="Subject_AreaProps">
> <xsl:value-of select="Name"/>
> <xsl:value-of select="Definition"/>
> </xsl:template>
>
> </xsl:stylesheet>
>
> -----Original Message-----
> From: Joseph Kesselman [mailto:keshlam@us.ibm.com]
> Sent: 24 October 2002 16:57
> To: 'xalan-j-users@xml.apache.org'
> Subject: Re: checking for null
>
> Try:    <xsl:if test="not($testlink)"> ?
>
> ______________________________________
> Joe Kesselman  / IBM Research
>
> The information contained in or attached to this message is confidential
> and is solely for the use of the addressee.  If you are not the intended
> recipient please notify us immediately by return email to
> postmaster@newton.co.uk
> and delete the message from your system. Internet communications
> are not secure.The Newton group and other subsidiaries of
> Mellon Europe Ltd accepts no liability for changes to this
> message after it was sent. Any views expressed by an individual in this
> email do not necessarily reflect the views of the group.  If you have
> any questions regarding the contents of this email please contact
> Information_Security@newton.co.uk