[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: xsl & unix functions
Thanks for your insights! > * Jirka Kosek <wvexn@xbfrx.pm> [2005-08-24 18:14:47 +0200]: > Sam Steingold wrote: > >> 1. this works, but is not too good because this is HTML-specific. on a second thought, this is not an issue. >> 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) > > There is one easy way how to implement this by misusing profiling > stylesheets (this is possible because internally profiling stylesheets > does two passes over input document). Just use profile-docbook.xsl I have huge documents. does this mean twice the processing time? > instead of docbook.xsl and put something like this into customization > layer: > > <xsl:template match="function[@role='unix']" mode="profile"> > <ulink url="{$unix.top}/functions/{.}"> > <xsl:copy-of select="."/> > </ulink> > </xsl:template> does this avoid infinite recursion? >> 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><sys/socket.h></filename> >> (but I do not want to have to enter the </> inside <filename>) > > Use same trick as above: > > <xsl:template match="filename[@role='unix']" mode="profile"> > <ulink url="{$unix.top}/basedefs/{string-after(., '/')}"> > <xsl:copy> > <xsl:copy-of select="@*"/> > <xsl:text><</xsl:text> > <xsl:apply-templates select="node()"/> > <xsl:text>></xsl:text> > </xsl:copy> > </ulink> > </xsl:template> is there a way to write <xsl:apply-templates> <xsl:text><</xsl:text> <xsl:copy-of select="@*"/> <xsl:text>></xsl:text> </xsl:apply-templates> more processing: 1. how to handle <command role="unix">make foo</command> and <command role="unix">make foo</command> is this supposed to work? <xsl:template match="command[@role='unix']"> <a class="{@role}" href="{$unix.top}utilities/{substring-before(.,'\s')}.html"> <xsl:apply-imports/> </a></xsl:template> (note regexp as the second argument to substring-before) 2. db_create --> ..../api_c/db_class.html db_env_create --> ..../api_c/env_class.html db_sequence_create --> ..../api_c/seq_class.html DB->set_bt_prefix --> ..../api_c/db_set_bt_prefix.html DB_ENV->set_encrypt --> ..../api_c/env_set_encrypt.html DB_MPOOLFILE->set_clear_len --> ..../api_c/memp_set_clear_len.html DB_SEQUENCE->set_cachesize --> ..../api_c/seq_set_cachesize.html DB_TXN->prepare --> ..../api_c/txn_prepare.html how do I handle this?! there are a handful (5) things like db_create above. there are a handful (6) things like DB_ENV above. there are dozens functions under each or DB_ENV, DB_TXN &c. thus: I need a transformation like this: (let ((dict (make-hash-table :test 'equal :initial-contents '(("db_create" . "db_class") ("db_env_create" . "env_class") ("db_sequence_create" . "seq_class") ("db_strerror" . "env_strerror") ("db_version" . "env_version") ("DB_LOGC" . "logc") ("DB_TXN" . "txn") ("DB_ENV" . "env") ("DB_SEQUENCE" . "seq") ("DB" . "db") ("DB_MPOOLFILE" . "memp"))))) (defun function-name-to-html (fn) (let ((pos (search "->" fn))) (if pos (concatenate 'string (gethash (substring fn 0 pos) dict) "_" (substring fn (+ pos 5))) (or (gethash fn dict) fn))))) <xsl:template match="function[@role='bdb']"> <a class="{@role}" href="{$bdb.top}api_c/{function-name-to-html(.)}.html"/> <xsl:apply-imports/> </a></xsl:template> Thanks again! -- Sam Steingold (http://www.podval.org/~sds) running w2k <http://www.savegushkatif.org> <http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/> <http://ffii.org/> Democrats, get out of my wallet! Republicans, get out of my bedroom!
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]