minor JAXP annoyance

Discussion in 'Java' started by paulmlieberman@alum.mit.edu, Dec 15, 2004.

  1. Guest

    I've got an XSLT stylesheet which I've written and maintained for over
    2 years now. I've always simply processed it with java
    org.apache.xalan.xslt.Process, but now I'm trying to speed things up,
    by compiling the stylesheet once, and processing hundreds of XML docs
    with it. The output is HTML.

    This is Java 1.4.1 on a Sparc9.

    The relevant code:
    in main():
    TransformerFactory tFactory = TransformerFactory.newInstance();
    translet = tFactory.newTemplates(new StreamSource(xslInURI));

    and then, in a method:

    Transformer transformer = translet.newTransformer();
    transformer.setParameter("baseurl", baseurlParam);
    transformer.setParameter("directory", dirParam);
    transformer.setParameter("imageurl", imageParam);
    transformer.transform(new StreamSource(xmlInURI),
    new StreamResult(new
    FileOutputStream(htmlOutURI)));

    The problem is, unlike when using Process, the following bit of XSLT
    inserts a newline between the </img> and the </a>, which causes the
    HTML to display an undesirable underscore after cite.gif (which is a
    small paragraph symbol the user is expected to click to invoke the
    javascript).

    In the source for this stylesheet, all the text within the <xsl:if> is
    on a single line of nearly 700 characters.


    <xsl:if test="@seqNum">
    <a><xsl:attribute
    name="href">javascript:showCitation(&apos;<xsl:value-of
    select="$citableAuthors"/>&apos;,&apos;<xsl:value-of
    select="$citableTitle"/>&apos;,&apos;<xsl:value-of
    select="$journalName"/>&apos;,&apos;<xsl:value-of
    select="$volume"/>&apos;,&apos;<xsl:value-of
    select="$pages"/>&apos;,&apos;<xsl:value-of
    select="$citableSectionTitle"/>&apos;,&apos;<xsl:value-of
    select="@seqNum"/>&apos;)</xsl:attribute><img border="0"><xsl:attribute
    name="src">/images/cite.gif</xsl:attribute><xsl:attribute
    name="alt"><xsl:value-of select="$citableAuthors"/> S-<xsl:value-of
    select="ancestor::*/@sectNum"/> #<xsl:value-of
    select="@seqNum"/></xsl:attribute></img></a>
    </xsl:if>

    - Paul M Lieberman
    American Psychological Association
     
    , Dec 15, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. PL
    Replies:
    0
    Views:
    2,647
  2. Chris

    JavaHelp annoyance

    Chris, Apr 6, 2006, in forum: Java
    Replies:
    1
    Views:
    374
    Bjorn Abelli
    Apr 6, 2006
  3. rf

    annoyance question

    rf, Nov 16, 2003, in forum: HTML
    Replies:
    27
    Views:
    766
  4. David Baxter

    Javascript / IE6 Annoyance

    David Baxter, Apr 8, 2005, in forum: HTML
    Replies:
    2
    Views:
    497
    Csaba Gabor
    Apr 9, 2005
  5. Bloody Viking

    minor JAXP annoyance

    Bloody Viking, Dec 16, 2004, in forum: XML
    Replies:
    1
    Views:
    407
    Joris Gillis
    Dec 16, 2004
Loading...

Share This Page