Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 19th, 2013, 11:23 AM
Authorized User
 
Join Date: Apr 2010
Posts: 61
Thanks: 12
Thanked 0 Times in 0 Posts
Default How To Check Multiple Elements Within Same Position

Hello.

I have the following XML.
Code:
        <DETAIL>
            <DETAILLINE>
                <SEQUENCE>000001</SEQUENCE>
                <DOS>
                    <MM>06</MM>
                    <DD>22</DD>
                    <YYYY>2011</YYYY>
                </DOS>
                <RCDATA>
                    <RCDATALINE>
                        <RC>BR</RC>
                        <RCOVERRIDE>Y</RCOVERRIDE>
                    </RCDATALINE>
                    <RCDATALINE>
                        <RC>38</RC>
                        <RCOVERRIDE>N</RCOVERRIDE>
                    </RCDATALINE>
                </RCDATA>
            </DETAILLINE>
            <DETAILLINE>
                <SEQUENCE>000002</SEQUENCE>
                <DOS>
                    <MM>06</MM>
                    <DD>11</DD>
                    <YYYY>2011</YYYY>
                </DOS>
                <RCDATA>
                    <RCDATALINE>
                        <RC>BR</RC>
                        <RCOVERRIDE>Y</RCOVERRIDE>
                    </RCDATALINE>
                    <RCDATALINE>
                        <RC>40</RC>
                        <RCOVERRIDE>N</RCOVERRIDE>
                    </RCDATALINE>
                </RCDATA>
            </DETAILLINE>
            <DETAILLINE>
                <SEQUENCE>000003</SEQUENCE>
                <DOS>
                    <MM>06</MM>
                    <DD>11</DD>
                    <YYYY>2012</YYYY>
                </DOS>
                <RCDATA>
                    <RCDATALINE>
                        <RC>BR</RC>
                        <RCOVERRIDE>Y</RCOVERRIDE>
                    </RCDATALINE>
                    <RCDATALINE>
                        <RC>40</RC>
                        <RCOVERRIDE>N</RCOVERRIDE>
                    </RCDATALINE>
                </RCDATA>
            </DETAILLINE>
        </DETAIL>
I received help here in this forum last week (thank you Michael Kay) as to how to check for <DOS> century, year and month less than '201107'.

I now need to add an additional test to only retrieve <DOS> less than '201107' and <DETAILLINE><RCDATA><RCDATALINE><RC> = '40' and
<DETAILLINE><RCDATA><RCDATALINE><RCOVERRIDE> != 'Y'.

The requirement is that the tests are all on the same position of <DETAILLINE>.

So, in the XML above, the only <DETAILLINE> that is true is <SEQUENCE>000002</SEQUENCE>.

I tried using the following but did not get the desired results.
Code:
 <xsl:when test="/doc/EOB/DETAIL/DETAILLINE/DOS[number(concat(YYYY,MM)) < 201107]  [/doc/EOB/DETAIL/DETAILLINE/RCDATA/RCDATALINE/RC = '40']  [/doc/EOB/DETAIL/DETAILLINE/RCDATA/RCDATALINE/RCOVERRIDE != 'Y']">
I'm thinking I need to use the "position" method but am not sure of the syntax.

I'm using XSLT version 1.0.

Any help will be greatly appreciated!

Thanks,
Rita
 
Old March 19th, 2013, 06:50 PM
Authorized User
 
Join Date: Apr 2010
Posts: 61
Thanks: 12
Thanked 0 Times in 0 Posts
Default How To Check Multiple Elements Within Same Position

I was finally able to get what I want using this code.
Code:
<xsl:when test="/doc/EOB/DETAIL/DETAILLINE/DOS[number(concat(YYYY,MM)) &lt; 201107]/../RCDATA/RCDATALINE[RC='40'][RCOVERRIDE!='Y']">





Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting multiple elements from multiple files Daedalus XSLT 2 October 10th, 2012 10:31 AM
Checking an Element Against Multiple Elements ritagr XSLT 8 May 26th, 2011 07:18 PM
How to check whether an elements contains another elements or not? metinhoclam XSLT 5 August 14th, 2010 10:11 AM
Insert multiple elements based on values of others fixit XSLT 14 September 25th, 2009 05:36 AM
Selecting multiple elements from the source XML mkansal XSLT 15 June 18th, 2007 09:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.