xsl-list
[Top] [All Lists]

[xsl] XPATH problem

2008-11-07 07:50:22
Hi guys,

This is related to a query I had some weeks ago (in case it sounds
familiar to someone).

I am processing a document that comes from a database.  Its structure is
that it has an <Institution> document element.  The <Institution>
element has <Module>, <Course>, and <Student> elements.

The <Student> element contains - amongst other things - a <HUSIC>
element (simple type and key from the student table), an <FNAMES>
element (simple type), and an <Instance> element.

The <Instance> element has, amongst other things, a <REDUCEDI> element.

I'm processing the source data using <xsl:for-each> elements in the xsl.
The current code I am writing is withing such and element as follows:

<xsl:for-each select="s0:Institution/s0:Student">
        ...
</xsl:for-each>

In the xsl, I want to express the notion that an <FNAMES> element should
only be included where there exists a <REDUCEDI> element in an any
<Instance> below the current <Student> having a value of '00' or '04'.

This should result in the exclusion of this element for 45 students.

First of all, I tried the following:

<xsl:for-each select="s0:Institution/s0:Student">
        ...
        <xsl:if test="s0:Instance/REDUCEDI[.='00' or .='04'">
                <FNAMES>
                        ...
                </FNAMES>
        </xsl:if>
        ...
</xsl:for-each>

This resulted in an <FNAMES> element being present for every student
including the 45 whom we knew were code '03' in their associate
Instance/REDUCEDI elements.

Next I tried:

<xsl:for-each select="s0:Institution/s0:Student">
        ...
        <xsl:if
test="/s0:Institution/s0:Student[s0:HUSID=current()]/s0:Instance/s0:REDU
CEDI[.='00' or .='04']">
                <FNAMES>
                        ...
                </FNAMES>
        </xsl:if>
        ...
</xsl:for-each>

This resulted in no students having an <FNAMES> element.  I.e. the
output document never contained an <FNAMES> element for a <Student>

Can someone spot where my XPATH statements are going astray, please?

Many 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>