classpathx-xml
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Classpathx-xml] Runtime exception thrown while using XsltFilter in pipe


From: Artur Matos
Subject: [Classpathx-xml] Runtime exception thrown while using XsltFilter in pipeline
Date: Sun, 18 Jul 2004 19:13:34 -0700 (PDT)

Hi to all,

I have just started using JAXP (GNU or otherwise), so
first of all I am sorry if this is a rather basic
question. I am trying to build a very simple pipeline
with the gnu.xml.pipeline package: basically for
reading an input XML file, processing it via XSLT, and
displaying the transformation in the standard output.
The problem is that my program always throws a
java.lang.RuntimeException at the XSLT stage,
something like this:

Exception in thread "main" java.lang.RuntimeException
        at
org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:3407)
        at
org.apache.xalan.transformer.TransformerHandlerImpl.endDocument(TransformerHandlerImpl.java:433)
        at
gnu.xml.aelfred2.SAXDriver.parse(SAXDriver.java:334)
        at
gnu.xml.aelfred2.XmlReader.parse(XmlReader.java:294)
        at
org.deriva.pipeliner.Pipeliner.main(Pipeliner.java:63)

Both program and used files can be found at the end of
this message. I have tried to change the XSLTFilter
step for other stages and it works perfectly, so the
problem should lie there. I have also tried with
different SAXDrivers and XSLT processors -- Xerces,
Xalan and SAXON -- and I always have the same problem.
I have also tried to transform the document from the
command line, with both xsltproc and the xalan command
line utility and it works perfectly with both.  

I now that the problem should be rather basic, but I
really cannot find it at all by myself.  Any help will
be kindly appreciated. Thanks in advance.

Artur

pipeliner.java

public class Pipeliner {

    public static void main(String[] args) throws
Exception {

        // Simple, basic transformation for now, just for
testing gnu.xml.pipeline...
        InputSource input = new InputSource
("samples/simpletransform/source.xml");

        XMLReader producer;
        EventConsumer consumer;

        producer = XMLReaderFactory.createXMLReader ();

        TextConsumer textConsumer = new
TextConsumer(System.out);

        File xsltFile = new
File("samples/simpletransform/xml2html.xsl");

        String xsltURI = xsltFile.toURI().toString();

        System.out.println("xsltURI =" + xsltURI);

        consumer = new XsltFilter(xsltURI, textConsumer);

        EventFilter.bind (producer, consumer);
        producer.parse (input);

        System.out.println("Done.");

    }

}

source.xml:

<document>

 <title>Simple document</title>

 <contents>

  <para>This is a sample paragraph</para>

  <para>This is a sample paragraph 2</para>

  <para>This is a sample paragraph 3</para>

  <para>This is a sample paragraph 4</para>

  <para>This is a sample paragraph 5</para>


 </contents>


</document>

xml2html.xsl:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

  <xsl:output method="html"/>

  <xsl:template match="/document">
    <html>
      <head><title><xsl:value-of select="title"
/></title></head>
      <body>
        <xsl:apply-templates select="contents" />
      </body>
    </html>
  </xsl:template>

  <xsl:template match="contents">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="para">
    <p><xsl:value-of select="." /></p>
  </xsl:template>


</xsl:stylesheet>



                
__________________________________
Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!
http://advision.webevents.yahoo.com/yahoo/votelifeengine/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]