xsl-list
[Top] [All Lists]

[xsl] Complex condition

2008-10-01 06:35:14
Hi (yes it's me again!)

I have a complex condition to sort out.  At the moment, I have
(incorrectly):

...
<!-- NULL is valid for PHDSUB -->
<xsl:if
test="/s0:HesaSqlExplicit_Response/s0:Institution/s0:Course/s0:COURSEAIM
/text() = 'D00'">
  <PHDSUB>
    <xsl:if test="s0:PHDSUB/text()">
      <xsl:value-of select="s0:PHDSUB"/>
    </xsl:if>
    <xsl:if test="not(s0:PHDSUB/text())">
      <xsl:attribute name="ReasonForNull">
        <xsl:text>9</xsl:text>
      </xsl:attribute>
    </xsl:if>
  </PHDSUB>
</xsl:if>
...

(I know the text() instances are redundant following our discussions
yesterday.  I haven't had chance to weed them all yet)

The PHDSUB element lives in a complex element called 'Instance'.  This
is related to other complex elements like this:

HesaSqlExplicit_Response
  |
  |
  +-- Institution (0:1)
        |
        |
        +-- Student (1:unbounded)
        |      |
        |      |
        |      +-- Instance (1:unbounded)
        |
        +-- Module (1:unbounded)
        |
        |
        +-- Course (1:unbounded)


Instance contains, amongst other things, the simple elements PHDSUB
element and COURSEID.

Course contains the simple elements COURSEID and COURSEAIM.

The condition I'm trying to express is that a PHDSUB should only appear
in the output tree if the COURSEAIM element in Course has the value
'D00'  and where (the bit that I'd not accounted for) the COURSEID
element of Course is equal to the COURSEID element of the the current
Instance.

Obviously at the moment my condition only looks at the COURSEID in,
presumably, the first Course that it comes to - which happens to equal
'D00' and so the condition is always returning true.  Not what I want.

I guess I need a predicate.  So am I on the right track looking at
something like:

test="/s0:HesaSqlExplicit_Response/s0:Institution/s0:Course[s0:COURSEID
= ./s0:COURSEID]/s0:COURSEAIM = 'D00'"

??

I don't know - amongst lots of other things I don't know - whether this
distinguishes between 'Instance.COURSEID' and 'Course.COURSEID'.  And
I'm not at all sure of the predicate because to the best of my
remembrance I've never used one before in anger.

Thanks


Peter


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>