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: Re: [docbook-apps] Syntax Highlighting


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
<?xml version="1.0"?>
<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"/>
  <!-- cool stuff here -->
  <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>
      <!-- Blow up if you can't highlight-->
      <xsl:when test="$highlight.source != 0"> <!--and
function-available('hl:highlight')"> -->
        <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>
      <!-- No syntax highlighting -->
      <xsl:otherwise>
        <xsl:apply-templates/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="language.to.xslthl">
    <xsl:param name="context"/>
    <!-- Expand content (to handle e.g. <textdata fileref="..."/>) -->
    <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>
      <!-- Files containing </ are considered to be XML files -->
      <xsl:when test="contains($content, '&lt;/')">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


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