More metadata in LFS xml

Dan Nicholson dbn.lists at
Thu Jul 19 11:00:13 PDT 2007

On 7/19/07, <macana at> wrote:
> El Jueves, 19 de Julio de 2007 15:34, Dan Nicholson escribió:
> > What I can't get right is the $name-$version part. I'm playing with
> > the dump-commands.xsl stylesheet in the LFS repo since it's simpler
> > than lfs.xsl in jhalfs. It seems like the place you would want to have
> > this to work easily with the rest of the stylesheet is to have them be
> > child elements (or attributes) of <sect1>.
> >
> > <sect1>
> >   <package name="glibc" version="&glibc-version;"/>
> >   ...
> > </sect1>
> A "proper" syntax could be:
> <sect1>
>   <sect1info>
>     <productname>glibc</productname>
>     <productnumber>&glibc-version;</productnumber>
>   </sect1info>
> But I don't like it.

I don't mind that too much and may be necessary to solve a different
issue below.

> > Is there a better way this could be done? Also, are there any limits
> > to what can be placed in a processing instruction? Is there any reason
> > we couldn't define our own custom pi?
> >
> > <?package glibc &glibc-version;?>
> Creating a PI is a more elegant solution, IMHO. PIs can be placed anywhere and
> are ignored by default by the XML/XSL processors. They are parsed only if
> there is a stylesheet that explicity matches it.

The problem is that the entities aren't resolved within the PIs, so it
just comes out as &glibc-version;.

Another option I thought of was to use a custom DTD for <sect1> by
just overloading the standard DocBook one with a local one. But I'd
prefer not to do that since it adds potential for errors in the local
sect1 definition.

> Another beast is to create such stylesheet. If you can't do it, I will try to
> play with this night or tomorrow.

It's was actually fairly simple now that I read some of the XSLT book
I purchased ages ago. Here's something similar I was using when I
stuffed the name and version in the label attribute. That was not a
good idea, but just changing the variable definitions to parse the
processing-instruction worked, too. (Watch out for gmail wrapping, and
ignore the $newline variable, which seems nicer than always hardcoding
the newline entity).


diff --git a/BOOK/stylesheets/dump-commands.xsl b/BOOK/stylesheets/dump-commands
index 9e2af96..e253c6d 100644
--- a/BOOK/stylesheets/dump-commands.xsl
+++ b/BOOK/stylesheets/dump-commands.xsl
@@ -15,6 +15,9 @@

   <xsl:template match="sect1">
+      <!-- Package name and version -->
+    <xsl:variable name="package" select="substring-before(@label,' ')"/>
+    <xsl:variable name="version" select="substring-after(@label,' ')"/>
       <!-- The dirs names -->
     <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
     <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/
@@ -43,6 +46,16 @@
       <!-- Creating dirs and files -->
     <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
+      <xsl:text># build script for </xsl:text>
+      <xsl:value-of select="$package"/>
+      <xsl:value-of select="$newline"/>
+      <xsl:text>package=</xsl:text>
+      <xsl:value-of select="$package"/>
+      <xsl:value-of select="$newline"/>
+      <xsl:text>version=</xsl:text>
+      <xsl:value-of select="$version"/>
+      <xsl:value-of select="$newline"/>
+      <xsl:value-of select="$newline"/>
       <xsl:apply-templates select=".//screen"/>

More information about the alfs-discuss mailing list