OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: xsl & unix functions


I want
  <function role="unix">select</function>
and
  <ulink role="unix" url="foo">bar</ulink>
to be rendered with a link to the SUS page.
here is what I came up with so far:

<xsl:param name="unix.top"
           select="'http://www.opengroup.org/onlinepubs/007904975'"/>
<xsl:template match="function[@role='unix']">
 <a class="{@role}"><xsl:attribute name="href">
   <xsl:value-of select="$unix.top"/>
   <xsl:text>/functions/</xsl:text>
   <xsl:value-of select="."/>
   <xsl:text>.html</xsl:text>
  </xsl:attribute>
  <xsl:apply-imports/>
</a></xsl:template>

<xsl:template match="ulink[@role='unix']">
 <a class="{@role}"><xsl:attribute name="href">
   <xsl:value-of select="$unix.top"/>
   <xsl:text>/</xsl:text>
   <xsl:value-of select="@url"/>
  </xsl:attribute>
  <xsl:apply-templates/>
</a></xsl:template>

1. this works, but is not too good because this is HTML-specific.
   I want the element wrapped in <ulink> and then XSL re-applied.
   (to avoid infinite recursion, one would have to strip 'role="unix"'
   from the function element before re-application)

2. the exact same thing has to be done with variables, but
   <xsl:template match="function[@role='unix'] or varname[@role='unix']">
   does not work.
   what do I do?

3. <filename role="unix">sys/socket.h</filename>
   must be rendered with a link to
   "$unix.top"/basedefs/syssocket.h.html
   i.e., I need to strip "/" from "sys/socket.h"?
   also, I want it to be rendered as if it were written
   <filename>&lt;sys/socket.h&gt;</filename>
   (but I do not want to have to enter the &lt;/&gt; inside <filename>)

4. suppose the URL cannot be inferred from the element contents easily,
   instead I have a table: a file "map" where odd lines are link content
   and even lines are URLs.  I guess I need to read the file into a hash
   table and do somthing like this:

(defparameter *map* (make-hash-table :test 'equal))
;; read map:
(with-open-file (in "map")
  (loop for s1 = (read-line in nil nil) for s2 = (read-line in nil nil)
    while (and s1 s2)
    do (setf (gethash s1 *map*) s2)))
;; process <function role="clhs">FOO</function>
(let ((destination (gethash <xsl:value-of select="."/> *map*)))
  (if destination
      <ulink url="destination">
       (apply-imports <function><xsl:value-of select="."/></function>)
      </ulink>
      (error "unknown function")))

how do I express this in XSL?

thanks!

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.iris.org.il> <http://www.savegushkatif.org>
<http://www.dhimmi.com/> <http://www.honestreporting.com>
If you try to fail, and succeed, which have you done?



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]