Subject: Re: xml
To: Jan Schaumann <jschauma@netbsd.org>
From: Julio M. Merino Vidal <jmmv@menta.net>
List: netbsd-docs
Date: 02/03/2004 16:45:19
On Tuesday 03 February 2004 14:35, Jan Schaumann wrote:
> Simas Mockevicius <symka@netbsd.vejas.lt> wrote:
> > >	<xsl:output method="html" encoding="YOUR-ENCODING" indent="yes"/>
> >
> > all works now fine, but what about editing xsl files in NetBSD htdocs
> > dir? If I change,
> > all xml files will be in my encoding. Maybe we need to make separate
> > files for every translating language?
>
> Maybe create htdocs/share/xsl/<lang>.xsl which automagically gets
> included if the document to be created is in <lang>. ?
>
> Or set a specific variable in the .xml file that will trigger a certain
> action in htdocs/share/xsl/webpage.xsl ?

Hmm... let's see how this looks... We have to define lang="es" in the xml file
so that the stylesheet can use that value (if needed); in fact, the generated
.xml file contains multiple references to it.  OTOH, this needs to go in the
Makefile so we can choose the right xsl file to use.  (no, you can't use a
variable in an 'include' line, so things get a bit ugly...)

? share/xsl/netbsd-webpage-en.xsl
? share/xsl/netbsd-webpage-es.xsl
Index: share/xsl/webpage.xsl
===================================================================
RCS file: /cvsroot/htdocs/share/xsl/webpage.xsl,v
retrieving revision 1.3
diff -u -r1.3 webpage.xsl
--- share/xsl/webpage.xsl	2004/01/31 19:02:07	1.3
+++ share/xsl/webpage.xsl	2004/02/03 15:40:51
@@ -227,7 +227,7 @@
 <xsl:template match="parentsec">
   <xsl:variable name="parentsec" select="."/>
   <hr/>
-  <xsl:text>Back to </xsl:text>
+  <xsl:value-of select="$locale.backto" />
   <em><a href="{$parentsec/@url}"><xsl:value-of 
select="$parentsec/@text"/></a></em>
 </xsl:template>
 
Index: share/mk/web.site.mk
===================================================================
RCS file: /cvsroot/htdocs/share/mk/web.site.mk,v
retrieving revision 1.11
diff -u -r1.11 web.site.mk
--- share/mk/web.site.mk	2004/02/03 12:55:25	1.11
+++ share/mk/web.site.mk	2004/02/03 15:40:51
@@ -12,6 +12,8 @@
 # clean -- remove anything generated by processing
 #
 
+LANG?=	en
+
 .if exists(${.CURDIR}/../Makefile.inc)
 .include "${.CURDIR}/../Makefile.inc"
 .endif
@@ -61,7 +63,7 @@
 ISPELLOPTS?=	-l -p ${WEB_PREFIX}/en/share/dict/words ${ISPELLFLAGS}
 
 # Our customization files.
-XSLFILE?=	${WEB_PREFIX}/share/xsl/netbsd-webpage.xsl
+XSLFILE?=	${WEB_PREFIX}/share/xsl/netbsd-webpage-${LANG}.xsl
 LAYOUTFILE=	${WEB_PREFIX}/autolayout.xml
 XMLDEPS+=	${XSLFILE} ${LAYOUTFILE}
 
Index: es/Releases/formal-1.6/Makefile
===================================================================
RCS file: /cvsroot/htdocs/es/Releases/formal-1.6/Makefile,v
retrieving revision 1.5
diff -u -r1.5 Makefile
--- es/Releases/formal-1.6/Makefile	2004/02/03 12:52:53	1.5
+++ es/Releases/formal-1.6/Makefile	2004/02/03 15:40:51
@@ -12,6 +12,7 @@
 .endif
 
 DOCS+=		NetBSD-1.6.2.xml
+LANG=		es
 
 .include "${WEB_PREFIX}/share/mk/web.site.mk"
 
Index: es/Releases/formal-1.6/NetBSD-1.6.2.xml
===================================================================
RCS file: /cvsroot/htdocs/es/Releases/formal-1.6/NetBSD-1.6.2.xml,v
retrieving revision 1.1
diff -u -r1.1 NetBSD-1.6.2.xml
--- es/Releases/formal-1.6/NetBSD-1.6.2.xml	2004/02/03 12:52:53	1.1
+++ es/Releases/formal-1.6/NetBSD-1.6.2.xml	2004/02/03 15:40:52
@@ -4,7 +4,7 @@
          "http://docbook.sourceforge.net/release/website/2.2/website.dtd" [
 ]>
 
-<webpage id="netbsd-1.6.2">
+<webpage id="netbsd-1.6.2" lang="es">
 <config param="desc" value="NetBSD 1.6.2 Release Announcement"/>
 <config param="cvstag" value="$NetBSD: NetBSD-1.6.2.xml,v 1.1 2004/02/03 
12:52:53 jmmv Exp $"/>
 <config param="rcsdate" value="$Date: 2004/02/03 12:52:53 $"/>
@@ -470,6 +470,7 @@
 
 </sect2>
 
-<parentsec url="./" text="Versiones formales de NetBSD 1.6" />
 </sect1>
+
+<parentsec url="./" text="Versiones formales de NetBSD 1.6" />
 </webpage>



And then, each netbsd-website-${LANG}.xml file does this:

<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- html -*- -->

<!-- $NetBSD$ -->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:html="http://www.w3.org/1999/xhtml"
		version="1.0">

  <xsl:param name="locale.backto">Back to</xsl:param>

  <xsl:include href="netbsd-webpage.xsl" />

</xsl:stylesheet>

-- 
Julio M. Merino Vidal <jmmv@menta.net>
The NetBSD Project - http://www.NetBSD.org/