OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Conditional actions in XSL?

[ Lists Home | Date Index | Thread Index ]
  • From: Peter Murray-Rust <peter@ursus.demon.co.uk>
  • To: xml-dev@ic.ac.uk
  • Date: Wed, 28 Jan 1998 07:53:14

[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@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS