[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Conditional actions in XSL?
[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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|