Re: normalize-scape.mod.xsl
Vitaly Ostanin <[email protected]> Wed, 2 Jul 2003 17:59:28 +0400
| Newsgroups | gmane.text.docbook.db2latex.devel |
|---|---|
| Message-ID | <[email protected]> |
--=.z95mVWQlk7ikfK Content-Type: multipart/mixed; boundary="Multipart_Wed__2_Jul_2003_17:59:28_+0400_0831e050" --Multipart_Wed__2_Jul_2003_17:59:28_+0400_0831e050 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 2 Jul 2003 21:10:18 +0800 James Devenish <[email protected]> wrote: > Hi Vitaly, > > New ideas are welcome -- and it would be great for us to > improve language support -- but each idea needs to be assessed > for its practical value. > > In message <[email protected]> > on Wed, Jul 02, 2003 at 03:03:49PM +0400, Vitaly Ostanin wrote: > > > I, too, would like to have had this. But DocBook XSL > > > stylesheets, in general, are slow enough already. The > > > problem with using a recursive template is that it can > > > easily increase processing time by a factor of five. > > > > You right, modified style is slow, but XSLT is not for speed. > > It's not for slownees, either! :) I optimize my version of template name="scape" (attached). Now it used key() functionality from XSLT. Top of my normalize-scape.mod.xsl: <xsl:key name="entity" match="mapping" use="@key"/> <xsl:variable name="latex.mapping.vyt" select="document('latex.mapping.xml')"/> Now speed statistic is (tested with xsltproc --timing --repeat): original db2latex Applying stylesheet 20 times took 15469 ms vyt first (scape.xsl) Applying stylesheet 20 times took 88864 ms Saving result took 1 ms vyt second (scape2.xsl) Applying stylesheet 20 times took 34364 ms > > > we will still use the long, monolithic "scape" > > > template but it will be generated from a mapping file (not > > > hand-coded). > > > > I'm not sure, that is the right way. > > >From what I have seen, it is the most practical way so far. May be. > > > > LaTeX doesn't support unicode characters by their > > > > numbers, so each character need to be translated into > > > > valid latex. > > > > > > I haven't found that to be possible (but I'm not an XSLT > > > expert). > > > > It's easily doing with characters mapping, without any > > extensions. > > I don't believe you! If you can find someone who has > demonstrated that it is practical (or can explain how it could > be done) that would help us find a new solution for DB2LaTeX. I'll try :) > As far as I can see, you're suggesting that we use > substring(...) to iterate over every character in text() nodes > and then do lookups in a 65000-element mapping document(most > characters will require LaTeX packages to be loaded -- so there > is always a need for a LaTeX-based solution). It simply isn't > practical(time, space, software support) to do that. You can split all mapping base by languages (numbers ranged) and include only specified. BTW, you can to have 2 alternative variants: with monolithic "scape"; and with replaced from mapping base (separated from latex.mapping.xml). <skipped/> -- Regards, Vyt mailto: [email protected] JID: [email protected] --Multipart_Wed__2_Jul_2003_17:59:28_+0400_0831e050 Content-Type: text/xml; name="scape2.xsl" Content-Disposition: attachment; filename="scape2.xsl" Content-Transfer-Encoding: 7bit <xsl:template name="scape"> <xsl:param name="string"/> <xsl:if test="not(string-length($string)=0)"> <xsl:variable name="char" select="substring($string,1,1)"/> <xsl:for-each select="$latex.mapping.vyt"> <xsl:choose> <xsl:when test="count(key('entity',$char)) > 0"> <xsl:value-of select="key('entity',$char)/@text"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$char"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> <xsl:call-template name="scape"> <xsl:with-param name="string" select="substring($string,2)"/> </xsl:call-template> </xsl:if> </xsl:template> --Multipart_Wed__2_Jul_2003_17:59:28_+0400_0831e050-- --=.z95mVWQlk7ikfK Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE/AuVAd6sY3eC5PjQRAiArAKDEn4PNlnEY6X7RjtVbYnPEtM6m9QCgqEhX USGUE8FHplfZQ5KDV3bG230= =qtqt -----END PGP SIGNATURE----- --=.z95mVWQlk7ikfK-- ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01