[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Selecting User Defined Language tags for output in AutoTOC and AutoIndex
Based on the sample files you sent me, I can see how you can get the titles working correctly in autotoc.xsl. But before I get to that, I should point out that you can accomplish what you need without customizaing the DTD or the stylesheets. You can use profiling, where you put the text in <phrase> elements with a lang attribute: <phrase lang="en">Hello World</phrase> <phrase lang="es">Hola Globa</phrase> <phrase lang="fr">Halo Globé</phrase> The <phrase> element is permitted everywhere you might need it. Then use the profiling stylesheet to generate a document with only one language selected by setting a profiling parameter: xsltproc --stringparam profile.lang "es" \ -output esonly.xml \ profiling/profile.xsl \ myfile.xml Then you can process "esonly.xml" using the stock stylesheets for HTML or print output and everything will work properly. Another advantage of this approach is that <phrase> can contain any elements in %para.char.mix; so you can have some elements within your translated text rather than just #PCDATA as your DTD dictates. If profiling won't work for you, then you can fix the autotoc.xsl problem by adding this template to your customization layer: <xsl:template match="translations" mode="no.anchor.mode"> <xsl:if test="$OutLang = 'es'"> <xsl:value-of select="spanish"/> </xsl:if> <xsl:if test="$OutLang = 'en'"> <xsl:value-of select="english"/> </xsl:if> <xsl:if test="$OutLang = 'fr'"> <xsl:value-of select="french"/> </xsl:if> </xsl:template> The no.anchor.mode is used when processing titles for the table of contents. BTW, in order for your translated titles to validate, you'll need to add this to your DTD customization: <!ENTITY % local.title.char.mix "|translations" > Index entries will be harder. The indexterm templates select only the text nodes of an indexterm, specifically to avoid formatting within the index. The templates use lines like these to get just the text: <xsl:value-of select="primary"/> In your case, selecting just the text nodes means all three language text nodes will be included. You will have to do some extensive customization of autoidx.xsl templates to have them process the <translations> element to select the right language. Profiling may prove to be easier. Bob Stayton Sagehill Enterprises bobs@sagehill.net ----- Original Message ----- From: "Mykone Saunders" <mykone@i3dvr.com> To: <docbook-apps@lists.oasis-open.org> Sent: Friday, November 07, 2003 11:21 AM Subject: [docbook-apps] Selecting User Defined Language tags for output in AutoTOC and AutoIndex Hello I need some help customizing Docbook XSL AutoToC and AutoIndex feature. I am writing a technical manual in english, french, and spanish. I added elements to the DTD to translate any content areas see below. (Pardon my translation) <translations> <english>Hello World</english> <spanish>Hola Globa</spanish> <french>Halo Globé</french> </translations> I then customize XSL as shown below. <xsl:param name="OutLang">es</xsl:param> <xsl:template match="translations"> <xsl:if test="$OutLang = 'es'"> <xsl:value-of select="spanish"/> </xsl:if> <xsl:if test="$OutLang = 'en'"> <xsl:value-of select="english"/> </xsl:if> <xsl:if test="$OutLang = 'fr'"> <xsl:value-of select="french"/> </xsl:if> </xsl:template> The output works for anywhere in the document body except for Auto TOC. I haven't tried the AutoIndex as yet. I'm quite sure it would be same problem. Can you tell me if it's possible to add a customization layer to switch between the above languages in the AutoTOC and AutoIndex sections? Thanks in advance. To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org, or visit http://www.oasis-open.org/mlmanage/.
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]