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

Conditional actions in XSL?

  • From: Peter Murray-Rust <peter@u...>
  • To: xml-dev@i...
  • Date: Wed, 28 Jan 1998 07:53:14

xsl conditional else
[Forwarded to the list from Dr. Zheng Min]

>>
>>>I played with XSL and MSXSL in the last few days. One thing I'm trying to
>>do
>>>is to drop all the elements with date attribute < a specified date.
>>However,
>>>with my understanding of XSL, I couldn't figure out a good way to do this.
>>>
>>>The normal ways, I can think of, to do this are either:
>>>
>>>1.     XSL supports conditional actions, such as:
>>>        <target-element ...>
>>>        if condition
>>>            <children/>
>>>        else
>>>            do nothing
>>>        end
>>>(I don't believe XSL has such a feature, unless I overlooked something.
>The
>>>only thing I see similar is the attribute rules but it can only be
>>>'=Value'), or
>>>
>>>2.    in the scripts, one can write:
>>>        function filter (e) {
>>>            if calc(attribute) then
>>>                do something
>>>                <children/>
>>>            else
>>>                do something else
>>>            end
>>>    and in XSL body, one can use the following rules to filter output
>>>without skipping (or including all) its descendants:
>>>            <target-element/>
>>>            <eval>filter(this)</eval>
>>>
>>>There is a "hacking" way I can think of, but unfortunately, I can't test
>it
>>>because MSXSL doesn't seem to support 'mode' yet. Anyways, the 'hacking'
>>I'm
>>>trying to do it to use something like:
>>>            function check(e) {
>>>                ......
>>>            }            /* return true or false */
>>>            .......
>>>            <rule>
>>>                <target-element/>
>>>                 <children mode="=check(this)"/>
>>>            </rule>
>>>
>>>            <rule mode="true">
>>>                .........
>>>            </rule>
>>>
>>>            <rule mode="false">
>>>                ......
>>>            </rule>
>>>
>>>I'm not sure if this works or not (it doesn't work with current MSXSL, at
>>>least).
>>>
>>>Can any knowledgeable people help me clarify the followings:
>>>
>>>1. Does XSL supports either the above 2 scenarios (i.e. condition in
>action
>>>rules or processing descendants in scripts). I may overlook something.
>>>
>>>2. If neither of above is available in XSL, what are the good work around?
>>>Will my 'hacking' work?
>>>
>>>Conditional action is a common feature. Very often an SGML/XML application
>>>needs to filter certain elements based on calculation (of attribute
>>values).
>>>IF XSL can't support this, I would say something essential is missing from
>>>XSL.
>>>
>>>Any comments?
>>>
>>>Thanks,
>>>Min
>>>
>>
>>
>>
>
>
Peter Murray-Rust, Director Virtual School of Molecular Sciences, domestic
net connection
VSMS http://www.nottingham.ac.uk/vsms, Virtual Hyperglossary
http://www.venus.co.uk/vhg

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.