cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicola Ken Barozzi" <nicola...@supereva.it>
Subject Re: [Cocoon Devel] Re: [C2] UML Class Diagram for SiteMap
Date Thu, 07 Sep 2000 08:08:05 GMT
----- Original Message -----
From: "Nicola Ken Barozzi" <nicolaken@supereva.it>

> ----- Original Message -----
> From: "Giacomo Pati" <pati_giacomo@yahoo.com>
> >
> > --- Nicola Ken Barozzi <nicolaken@supereva.it> wrote:
> > >
> > > ----- Original Message -----
> > > From: "Giacomo Pati" <pati_giacomo@yahoo.com>
> > > To: <cocoon-dev@xml.apache.org>
> > > Sent: Thursday, September 07, 2000 8:48 AM
> > > Subject: Re: [Cocoon Devel] Re: [C2] UML Class Diagram for SiteMap
> > >
> > > > I've written a stylesheet that presents the sitemap as a html page.
> > > > I'll want to write an admin app (using C2 of course) for the
> > > sitemap.
> > > > But have problems with the FileGenerator not passing Namespaces
> > > > declaration correctly to the transformer. When you insert the
> > > following
> > > > into the <map:pipeline> of the sitemap.xmap file
> > > >
> > > >   <map:match pattern="sitemap">
> > > >    <map:generate src="sitemap.xmap"/>
> > > >    <map:serialize type="xml"/>
> > > >   </map:match>
> > > >
> > > > and request it as
> > > >
> > > >   http://localhost:8080/cocoon/sitemap
> > > >
> > > > you'll see that the xmlnx:map.... has been removed. Have no idea
> > > why?
> > > > Does someone elso do?
> > >
> > > Hmmm... In my Transformer (class) the namespaces are called correctly
> > > with
> > > Xerces 1.2 and with 1.1.3 are called but give an exception at the
> > > end, so
> > > I'm not sure it's the FileGenerator, maybe it's the Serializer that
> > > kicks them off.
> >
> > You're right. I've used the LogTransformer now to see what the
> > FileGenerator outputs. And the output seems to be ok. But why does the
> > simple-sitemap2html.xsl not match _any_ template ???
> Maybe in XalanTransformer this line?
>
>  this.setDocumentHandler(this.processor);
>
> does a DocumentHandler forward namespace events?

Yes.

Are the stylesheets compiled? I got this from http://xml.apache.org/xalan/usagepatterns.html
.
Are we setting up Xalan right?

/***********/

      Generating and responding to SAX events


To set up a transformation to generate SAX events, set the DocumentHandler property of the
XSLTResultTarget object. The
transformation consumer can then respond to these events as they occur, rather than waiting
(as the consumer of a DOM must) for the
complete result tree.

This example sends the output to System.out.


     import org.apache.xalan.xslt.XSLTProcessor;
import org.apache.xalan.xslt.XSLTInputSource;
import org.apache.xalan.xslt.XSLTResultTarget;
import org.apache.xalan.xslt.XSLTProcessorFactory;
import org.apache.xalan.xslt.StylesheetRoot;

public class TransformToSax
{
	public static void main(String[] args)
    throws java.io.IOException,
           java.net.MalformedURLException,
           org.xml.sax.SAXException
	{
    XSLTProcessor processor = XSLTProcessorFactory.getProcessor();

    // Set the processor to use a compiled stylesheet.
    // The stylesheet provides access to a SAX DocumentHandler,
    // passing it the stylesheet xsl:output settings.
    StylesheetRoot stylesheet = processor.processStylesheet("foo.xsl");
    // This property was just set implicitly, but for good form...
    processor.setStylesheet(stylesheet);
    // In this case, send the output to System.out.
    org.xml.sax.DocumentHandler dh = stylesheet.getSAXSerializer(System.out);

    // Use the DocumentHandler to construct an XSLTResultTarget object.
    XSLTResultTarget saxResult = new XSLTResultTarget(dh);

    // Perform the transformation. The stylesheet parameter is null, so
    // the processor uses the compiled stylesheet identified by its
    // Stylesheet property setting.
    processor.process(new XSLTInputSource("foo.xml"), null, saxResult);
	}
}



XSLTProcessor also has a DocumentHandler property. By setting this property, you instruct
the processor to process a sequence of SAX
events. The processor needs a compiled stylesheet to perform this transformation.



/*********/

nicola_ken


Mime
View raw message