|
Subject: RE: [xsl] Implementing a (fairly) complex business rule From: "Bradley, Peter" <pbradley@xxxxxxxxxx> Date: Tue, 30 Sep 2008 15:08:11 +0100 |
Ah! Misplaced parenthesis. I have it right everywhere else.
However I need to address the other problems you raise ...
First, there's the context. Here is a fragment that should give you
enough (if not please say):
...
<xsl:for-each select="s0:EntryProfile">
<EntryProfile>
<DOMICILE>
<xsl:attribute name="codeListAgencyName">
<xsl:text>HESA</xsl:text>
</xsl:attribute>
<xsl:attribute name="codeListName">
<xsl:text>DOMICILE</xsl:text>
</xsl:attribute>
<xsl:attribute name="languageID">
<xsl:text>en</xsl:text>
</xsl:attribute>
<xsl:value-of select="s0:DOMICILE/text()"/>
</DOMICILE>
<!-- NULL is valid for a postcode -->
<xsl:if
test="/s0:HesaSqlExplicit_Response/s0:Institution/s0:Student/s0:Instance
/s0:REDUCEDI = '00'">
<xsl:if
test="s0:DOMICILE='XF' or s0:DOMICILE='XG' or s0:DOMICILE='XH'
or s0:DOMICILE='XI' or s0:DOMICILE='XK' or s0:DOMICILE='XL' or
s0:DOMICILE='GG' or s0:DOMICILE='JE' or s0:DOMICILE='IM'">
<POSTCODE>
<xsl:if test="string-length(s0:POSTCODE/text()) = 0">
<xsl:attribute name="ReasonForNull">
<xsl:text>1</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:if test="string-length(s0:POSTCODE/text()) > 0">
<xsl:value-of select="s0:POSTCODE/text()"/>
</xsl:if>
</POSTCODE>
</xsl:if>
</xsl:if>
...
The input file is highly data-oriented (it comes from a set of database
tables).
Am I right in thinking, from what you say, that I need to test for
non-empty node by doing:
<xsl:if test="s0:POSTCODE/text()">
<xsl:value-of select="s0:POSTCODE/text()"/>
</xsl:if>
Presumably the test for an empty node in the other xsl:if statement
should be:
<xsl:if test="not(s0:POSTCODE/text())"> ...
I'm guessing the logical not from the fact that 'and' and 'or' are used.
I can check that for myself if you're getting exasperated with my
ignorance :(
I do apologise for my obvious lack of sophistication in matters xslt.
I've rather had this dumped on me, having not looked at xslt for over
three years and even then at a very basic level. I am enjoying it,
though.
Many thanks
Peter
-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: 30 September 2008 14:35
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Implementing a (fairly) complex business rule
> I just cannot see how this can happen.
test="string-length(s0:POSTCODE/text() = 0)"
is always true as it is taking the value returned by string-length as a
boolean, which is true if it is non zero
the string being passed to string-length is either "true" or "false"
depending on whether
s0:POSTCODE/text() = 0
is true or not, which is true just if one of the text node children of
s0:POSTCODE is "0".
but neither "true" nor "false" have zero length, so the test is always
true.
David
________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Implementing a (fairly) c, David Carlisle | Thread | Re: [xsl] Implementing a (fairly) c, David Carlisle |
| RE: [xsl] Implementing a (fairly) c, Michael Kay | Date | RE: [xsl] Implementing a (fairly) c, Bradley, Peter |
| Month |