docbook-apps

  • 1.  Re: [docbook-apps] Syntax Highlighting

    Posted 03-15-2007 09:49
    I've used xslthl.jar with 1.72.0 and Saxon 6.5.5. I think it is the best
    approach.
    Can you provide more details on how you are using it?

    Bob Stayton
    Sagehill Enterprises
    DocBook Consulting
    bobs@sagehill.net


    ----- Original Message -----
    From: "Keith Fahlgren" <abdelazer@gmail.com>
    To: "apps docbook" <docbook-apps@lists.oasis-open.org>
    Sent: Wednesday, March 14, 2007 3:06 PM
    Subject: [docbook-apps] Syntax Highlighting


    > Hey,
    >
    > Just wanted to get the current consensus on the state of syntax
    > highlight for FO. XSLTHL[1] looks nice, but I can't get it
    > running...[2]. Bob mentions JEdit Syntax[3], which I think I can find
    > more on in the archives[4].
    >
    > Does anyone have a syntax coloring technique that they particularly
    > like? Does it add some semantic richness, or is all code/@role based?
    >
    >
    > Thanks,
    > Keith
    >
    > 1. http://xmlguru.cz/2006/07/docbook-syntax-highlighting
    > 2. Using 1.72.0, various saxons, apparently proper class path and -D
    > setting... (" The URI java:net.sf.xslthl.ConnectorSaxon6 does not
    > identify an external Java class")
    > 3. http://www.sagehill.net/docbookxsl/SyntaxHighlighting.html
    > 4. And other, older solutions like
    > http://sources.redhat.com/ml/docbook-apps/2003-q3/msg00421.html
    >
    > ---------------------------------------------------------------------
    > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
    >
    >
    >





  • 2.  Re: [docbook-apps] Syntax Highlighting

    Posted 03-15-2007 15:48
    On 3/15/07, Bob Stayton <bobs@sagehill.net> wrote:
    > I've used xslthl.jar with 1.72.0 and Saxon 6.5.5. I think it is the best
    > approach.

    Ah, glad to see that someone got it going.[1] :-)

    > Can you provide more details on how you are using it?

    Yeah, here is my Saxon6.5 attempt:

    $ ./highlight-fo.sh -o ch09.fo ch09.xml
    /work/tools/keith/devprod/trunk/oneoffs/highlight6.xsl
    Making portrait pages on USletter paper (8.5inx11in)
    potentially highlighting? false
    FOOO!
    Error at xsl:apply-templates on line 29 of
    file:/work/tools/keith/devprod/trunk/oneoffs/highlight6.xsl:
    The URI java:net.sf.xslthl.ConnectorSaxon6 does not identify an
    external Java class
    Transformation failed: Run-time errors were reported

    $ less highlight-fo.sh
    #!/bin/sh
    #SAXON="/usr/share/saxon/lib/saxon8.jar"
    #CP8="/work/tools/keith/scratch/xslthl-cvs/build/classes/net/sf/xslthl/ConnectorSaxon8.class:/work/tools/keith/scratch/xslthl-cvs/build/xslthl.jar"
    OLD_CP=$CLASSPATH
    export CLASSPATH=""

    SAXON="/usr/share/saxon/lib/old/6.5/saxon.jar"
    CP6="/work/tools/keith/scratch/xslthl-cvs/build/xslthl.jar"
    XSLTHL_CONFIG="/work/tools/docbook/highlighting/xslthl-config.xml"
    /usr/bin/java -classpath $CP6 -Dxslthl.config=$XSLTHL_CONFIG -Xmx1024m
    -jar $SAXON $*
    export CLASSPATH=$OLD_CP

    $ less /work/tools/keith/devprod/trunk/oneoffs/highlight6.xsl

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:xslthl="http://xslthl.sf.net"
    xmlns:hl="java:net.sf.xslthl.ConnectorSaxon6"
    xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
    xmlns:exsl="http://exslt.org/common"
    version="1.0"
    exclude-result-prefixes="xslthl exsl hl">
    <xsl:import href="../docbook-xsl/fo/docbook.xsl"/>

    <xsl:param name="highlight.source" select="1"/>

    <xsl:template name="apply-highlighting">
    <xsl:message>potentially highlighting? <xsl:value-of
    select="function-available('hl-highlight')"/> </xsl:message>
    <xsl:choose>

    <xsl:when test="$highlight.source != 0">
    <xsl:variable name="language">
    <xsl:call-template name="language.to.xslthl">
    <xsl:with-param name="context" select="."/>
    </xsl:call-template>
    </xsl:variable>
    <xsl:choose>
    <xsl:when test="$language != ''">
    <xsl:variable name="content">
    <xsl:apply-templates/>
    </xsl:variable>
    <xsl:apply-templates select="hl:highlight($language,
    exsl:node-set($content))"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:apply-templates/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:when>

    <xsl:otherwise>
    <xsl:apply-templates/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    <xsl:template name="language.to.xslthl">
    <xsl:param name="context"/>

    <xsl:variable name="content">
    <xsl:apply-templates select="$context/node()"/>
    </xsl:variable>
    <xsl:message>FOOO! </xsl:message>
    <xsl:choose>
    <xsl:when test="$context/@language != ''">
    <xsl:value-of select="$context/@language"/>
    </xsl:when>

    <xsl:when test="contains($content, '</')">xml</xsl:when>
    <xsl:otherwise>
    <xsl:text>c</xsl:text>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>
    </xsl:stylesheet>


    (I tried building a JAR from the CVS repo of XSLTHL and using a Saxon8
    Connector described here[1], but that failed in a similar way).




    Keith

    1. http://sourceforge.net/forum/forum.php?thread_id=1652381&forum_id=513404
    2. http://sourceforge.net/forum/forum.php?thread_id=1606945&forum_id=513404