[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Complex condition

Subject: Complex condition
From: "Bradley, Peter" <pbradley@xxxxxxxxxx>
Date: Wed, 1 Oct 2008 11:33:53 +0100
 Complex condition
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.