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

RE: Design of inheritance in XML and resolving it with

Subject: RE: Design of inheritance in XML and resolving it with XSLT
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 2 Aug 2006 11:03:49 +0100
RE:  Design of inheritance in XML and resolving it with
> Two designs come into mind:
> 
> Design I:
>    <style name="A">
>        <style-props prop-1="x" prop-2="y" prop-3="z"/>
>    </style>
>    <style name="B" parent="A">
>        <style-props prop-1="v" prop-22="yy" prop-33="zz"/>
>    </style>
> 
> Design II:
>    <style name="A">
>        <style-props prop-1="x" prop-2="y" prop-3="z"/>
>        <style name="B">
>            <style-props prop-1="v" prop-22="yy" prop-33="zz"/>
>        </style>
>    </style>
> 
> 
> In both design the style properties should be interpreted as:
> style 'A': prop-1=x, prop-2=y, prop-3=z
> style 'B': prop-1=v, prop-2=y, prop-3=z, prop-22=yy, prop-33=zz
> 
> What do you imagine is a better design?

I would tend to prefer II, but either is quite viable. The advantage of II
is that you can easily search for the nearest attribute using 

(ancestor-or-self::style/@prop-1)[last()]

whereas design I needs a recursive function (or template) to do the
navigation.

> 
> How can I map it most efficiently to absolute styles?
> Creating a large variable for all mapped styles right at the 
> beginning or map them just-in-time when found accepting 
> redundancy in multiple mapping of the same style?

With Saxon you could get the best of both worlds with a memo-function.

Otherwise it essentially depends on the average number of times each style
is "computed". If the average is much less than one, do it on-demand, if
it's much greater than one, do it eagerly; otherwise, you'll have to measure
to see where the cut-off comes.
> 
> In case the only way is the empiric approach to implement 
> both ways and test which is faster in an XSLT engine, any 
> links to such performance harness to reuse (preferable Java)?
> 

Remember that performance measurements will vary from one XSLT processor to
another. With Java, remember that warm-up time can dominate the measurement
- any measurement run should execute for at least 30 seconds to get
reproducible results.

Michael Kay
http://www.saxonica.com/

Current Thread

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
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-2007 All Rights Reserved.