cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oskar Casquero" <jtaca...@bi.ehu.es>
Subject Re: two components implementing parser role?
Date Fri, 15 Nov 2002 12:24:24 GMT
Thank you !

I've found another solution (I don't know if it is very good, but it does what I want and
it works). 

I've changed Parser interface and I've added to it the method:
    
    void myParse(InputSource in, ContentHandler consumer, boolean validation)

and in JaxpParser.java I've implemented this method:

    public void myParse( final InputSource in,
                       final ContentHandler consumer,
                       boolean validation )
        throws SAXException, IOException
    {
        /*Validation OnOff*/
        m_factory.setValidating( validation );

        if( consumer instanceof LexicalHandler )
        {
            parse( in, consumer, (LexicalHandler)consumer );
        }
        else
        {
            parse( in, consumer, null );
        }
    }

Then, to lookup the parser and use it:

    Parser parser = (Parser) this.manager.lookup(Parser.ROLE);
    boolean validation = parameters.getParameterAsBoolean("validation", false);
    parser.myParse(this.inputSource, super.xmlConsumer, validation);


Oskar

----- Original Message ----- 
From: "Maciek Kaminski" <maciejka@tiger.com.pl>
To: <cocoon-dev@xml.apache.org>
Sent: Friday, November 15, 2002 12:33 PM
Subject: Re: two components implementing parser role?


> On 13 Nov 2002 at 11:44, Oskar Casquero wrote:
> 
> > Hello,
> > 
> > I would like to know if it is posible to define two components that 
> > implement parser role: one ofwould be the default parser of cocoon 
> > (with its default configuration) and the other would use xerces 
> > parser but with the validation feature turned on ...
> 
> Although this question better suits cocoon-user list... 
> 
> One may define its own components in cocoon.xconf like this:
> 
> <component 
>     role="org.apache.avalon.excalibur.xml.Parser/Validating"
>     class="org.apache.avalon.excalibur.xml.JaxpParser">
>     <parameter name="validate" value="true"/>
>     <parameter name="namespace-prefixes" value="false"/>
>     <parameter name="stop-on-warning" value="true"/>
>     <parameter name="stop-on-recoverable-error" value="true"/>
>     <parameter name="reuse-parsers" value="false"/>            
> </component>
> 
> Then lookup:
> 
> Parser parser = (Parser)manager.lookup(Parser.ROLE + "/Validating");
> 
> P.S.: This looks like good subject for FAQ/How-To/Snippet, isnt it?
> 
> Maciek Kaminski
> maciejka@tiger.com.pl
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
> 
Mime
View raw message