[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Need help for XSL beautifaction
Christian,
At 01:27 PM 5/17/2006, you wrote: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0"> There is a nice application of the document() function, which is used to call in data from an external document, very useful for situations like this. document('') (with an empty string as argument) will return the stylesheet itself, as a tree of nodes that can be queried or even processed. This makes it straightforward to create and use internal lookup tables in a stylesheet: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <!-- Define Text-Modules --> <xsl:variable name="snip-lookup"> <snip name="text-1">This is long text number one.</snip> <snip name="text-2">This is an other very long text.</snip> <snip name="text-3">This is my third text without sense.</snip> </xsl:variable> <xsl:variable name="snippets" select="document('')/*/xsl:variable[@name='snip-lookup']/snip"/> The variable $snips now contains a set of nodes, namely all the 'snip' elements in the variable. (Note this is a tortuous workaround for something that would be very simple in XSLT 2.0, namely $snip-lookup/snip.) Then instead of a choose/when/otherwise we can simply say <xsl:apply-templates select="$snippets[@name=current()/textNo]"/> (or value-of, or whatever: it's the select expression that matters here.) This is all documented in the XSL FAQ under, I believe, "lookup tables". Improve performance of the lookup using keys. Regards, Wendell ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
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
|