[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Can this hard-coded template be generalized?
Hi Ken,
Your code works quite well. Thanks. My problem was that I was unable to say abstractly exactly what I wanted to do and resorted to the hard code example to picture what was needed. The source of that problem is that I cannot always picture accurately what is being presented at some specific processing instance and place. Oddly enough, because of that problem, although I had started with a close approximation of your code, I made some wrong initial assumptions about what I had in hand, followed by several mistaken corrections, which led to all that noise. I have, however, simplified a lot of code after we talked last week, but there are still many C++ fingerprints smeared on it. At 72, it is just a bit harder to change one's tricks. Thatbs why yesterday I asked the list for sources of XSLT design patterns. No sources, but got a misdirected affectionate note in French, though. Thanks again, Mark -----Original Message----- From: G. Ken Holman Sent: Sunday, October 02, 2011 1:37 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: Can this hard-coded template be generalized? At 2011-10-02 13:00 -0700, Mark wrote: Below are two abbreviated but complete files.
For example, I was able to quickly reproduce your results with this much shorter stylesheet: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cps="http://www.cpslib.org" exclude-result-prefixes="xs cps" version="2.0"> <xsl:template match="Stamp"> <xsl:result-document href="{../@year}-{CatNumbers/@pofis-number}.htm"> <html> <head/> <body> <a lang="en" class="button" href="{Formats/@complex}s.htm">Se-tenant</a> <a lang="cz" class="button" href="{Formats/@complex}s.htm">Spojky</a> </body> </html> </xsl:result-document> </xsl:template> </xsl:stylesheet> As before, it doesn't do any string decomposition after composition. Nor any un-grouping after grouping. And no tunneling was needed, nor even creating any variable and passing it as a subroutine as I was able to go and get the values as needed. I was looking at it declaratively and thinking about where to find tree nodes when needed. But ... the code above seems too simple to reflect what you might have been trying with the grouping, so I have no idea if it will help you or not. And I wasn't trying to be cryptic, just reducing creating variables where they weren't going to be reused often enough. Note how in some (not all) instruction attributes (above in xsl:result-document/@href) and in all literal result element attributes (above in a/@href) you can mix multiple attribute value templates and boilerplate text strings to compose the attribute's value. You don't have to use concat() as you did below. I hope this helps. . . . . . . . . . . . Ken Thanks, Mark ----------------------- -- Contact us for world-wide XML consulting and instructor-led training Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|
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
|