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

Re: A little cross referencing problem

Subject: Re: A little cross referencing problem
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Wed, 22 Aug 2001 20:33:39 -0700 (PDT)
meaning of cross referencing
Joerg Pietschmann wrote:

> Jeni Tennison <mail@xxxxxxxxxxxxxxxx> wrote:
> > Very sweet :) You could do the same kind of thing for decimal formats
> > to use with format-number().
> > 
> > Of course the only slight drawback is that the document('') call will
> > only get the current stylesheet document, and therefore won't search
> > for keys defined in imported or included stylesheets (or indeed
> > stylesheets in which this one is imported or included).
> > 
> > Perhaps functions like key-available() and decimal-format-available()
> > would be handy.
> 
> Yes. Either this or having something like document(/..) meaning the
> whole compiled style sheet... or, for more fun, document('xsl:this')...
> 
> Really hard-core XSLers will, of course, use recursive templates
> to search all included and imported files. Bonus points for buildung
> a global variable which holds all top-level xsl elements from the
> transitive closure as a node set. :-)

Here's a very simple collection of two templates (not at all hard-core!) that will
merge together all stylesheets (of a stylesheet module) that are referenced from a
main stylesheet directly or indirectly via xsl:include or xsl:import.


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" />

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()" />
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="xsl:include | xsl:import">
       <xsl:apply-templates select="document(@href)/*/node()"/>
    </xsl:template>
</xsl:stylesheet>
 

In the first pass you apply these templates to the root of any stylesheet and get
the output of this transformation into an xsl:variable.

In the second pass (xxx:node-set() will have to be used just once) you convert this
to a node-set and freely search for whatever xsl:key or other elements are of
importance.

Hope this helped.

Cheers,
Dimitre Novatchev.






__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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