Quantcast

Make xslt component not to validate dtd's (or use local copy)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Make xslt component not to validate dtd's (or use local copy)

Dirk Reske
Hello,

We are using the camel xslt component to transform a xhtml file. But for
transforming the file, the used XMLReader tries to download the dtd from thw
w3c website.

Is it possible, to tell the xslt component, to configure the xml reader to
use local version (e.g. by using xml catalogs) or not to validate dtd's at
all?

thanks
Dirk
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Make xslt component not to validate dtd's (or use local copy)

Claus Ibsen-2
On Tue, Feb 19, 2013 at 1:56 PM,  <[hidden email]> wrote:

> Hello,
>
> We are using the camel xslt component to transform a xhtml file. But for
> transforming the file, the used XMLReader tries to download the dtd from thw
> w3c website.
>
> Is it possible, to tell the xslt component, to configure the xml reader to
> use local version (e.g. by using xml catalogs) or not to validate dtd's at
> all?
>

Hi

You can use a custom uriResolver. Would that do the trick?
http://camel.apache.org/xslt

> thanks
> Dirk



--
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Make xslt component not to validate dtd's (or use local copy)

Dirk Reske-2
Hi,

no, the uriResolver is used to resolve the xslt file only.
I've found a way, using a processor, that creates a XMLReader using the CatalogResolver and puts a SAXSource using this xmlReader into the exchange.

@Override
public void process(Exchange exchange) throws Exception {
  InputStream inputStream = exchange.getIn().getBody(InputStream.class);

  XMLReader xmlReader = XMLReaderFactory.createXMLReader();
  xmlReader.setEntityResolver(new CatalogResolver());
  exchange.getIn().setBody(new SAXSource(xmlReader, new InputSource(inputStream)));
}

The Transformer used by the xsltComponent will then use this xmlReader.

Dirk

-------- Original-Nachricht --------
> Datum: Tue, 19 Feb 2013 20:04:54 +0100
> Von: Claus Ibsen <[hidden email]>
> An: [hidden email]
> Betreff: Re: Make xslt component not to validate dtd\'s (or use local copy)

> On Tue, Feb 19, 2013 at 1:56 PM,  <[hidden email]> wrote:
> > Hello,
> >
> > We are using the camel xslt component to transform a xhtml file. But for
> > transforming the file, the used XMLReader tries to download the dtd from
> thw
> > w3c website.
> >
> > Is it possible, to tell the xslt component, to configure the xml reader
> to
> > use local version (e.g. by using xml catalogs) or not to validate dtd's
> at
> > all?
> >
>
> Hi
>
> You can use a custom uriResolver. Would that do the trick?
> http://camel.apache.org/xslt
>
> > thanks
> > Dirk
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: [hidden email]
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Make xslt component not to validate dtd's (or use local copy)

Christian Mueller
Thanks for sharing your solution!

Sent from a mobile device
Am 20.02.2013 07:56 schrieb "Dirk Reske" <[hidden email]>:

> Hi,
>
> no, the uriResolver is used to resolve the xslt file only.
> I've found a way, using a processor, that creates a XMLReader using the
> CatalogResolver and puts a SAXSource using this xmlReader into the exchange.
>
> @Override
> public void process(Exchange exchange) throws Exception {
>   InputStream inputStream = exchange.getIn().getBody(InputStream.class);
>
>   XMLReader xmlReader = XMLReaderFactory.createXMLReader();
>   xmlReader.setEntityResolver(new CatalogResolver());
>   exchange.getIn().setBody(new SAXSource(xmlReader, new
> InputSource(inputStream)));
> }
>
> The Transformer used by the xsltComponent will then use this xmlReader.
>
> Dirk
>
> -------- Original-Nachricht --------
> > Datum: Tue, 19 Feb 2013 20:04:54 +0100
> > Von: Claus Ibsen <[hidden email]>
> > An: [hidden email]
> > Betreff: Re: Make xslt component not to validate dtd\'s (or use local
> copy)
>
> > On Tue, Feb 19, 2013 at 1:56 PM,  <[hidden email]> wrote:
> > > Hello,
> > >
> > > We are using the camel xslt component to transform a xhtml file. But
> for
> > > transforming the file, the used XMLReader tries to download the dtd
> from
> > thw
> > > w3c website.
> > >
> > > Is it possible, to tell the xslt component, to configure the xml reader
> > to
> > > use local version (e.g. by using xml catalogs) or not to validate dtd's
> > at
> > > all?
> > >
> >
> > Hi
> >
> > You can use a custom uriResolver. Would that do the trick?
> > http://camel.apache.org/xslt
> >
> > > thanks
> > > Dirk
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > Red Hat, Inc.
> > FuseSource is now part of Red Hat
> > Email: [hidden email]
> > Web: http://fusesource.com
> > Twitter: davsclaus
> > Blog: http://davsclaus.com
> > Author of Camel in Action: http://www.manning.com/ibsen
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Make xslt component not to validate dtd's (or use local copy)

Claus Ibsen-2
In reply to this post by Dirk Reske-2
On Wed, Feb 20, 2013 at 7:27 AM, Dirk Reske <[hidden email]> wrote:

> Hi,
>
> no, the uriResolver is used to resolve the xslt file only.
> I've found a way, using a processor, that creates a XMLReader using the CatalogResolver and puts a SAXSource using this xmlReader into the exchange.
>
> @Override
> public void process(Exchange exchange) throws Exception {
>   InputStream inputStream = exchange.getIn().getBody(InputStream.class);
>
>   XMLReader xmlReader = XMLReaderFactory.createXMLReader();
>   xmlReader.setEntityResolver(new CatalogResolver());
>   exchange.getIn().setBody(new SAXSource(xmlReader, new InputSource(inputStream)));
> }
>
> The Transformer used by the xsltComponent will then use this xmlReader.
>
> Dirk
>

Maybe the camel xslt component can be enhanced to support to plugin a
custom EntityResolver?

We love contributions so feel free to work on a patch for such an
improvement, if that is possible to do.
http://camel.apache.org/contributing.html



> -------- Original-Nachricht --------
>> Datum: Tue, 19 Feb 2013 20:04:54 +0100
>> Von: Claus Ibsen <[hidden email]>
>> An: [hidden email]
>> Betreff: Re: Make xslt component not to validate dtd\'s (or use local copy)
>
>> On Tue, Feb 19, 2013 at 1:56 PM,  <[hidden email]> wrote:
>> > Hello,
>> >
>> > We are using the camel xslt component to transform a xhtml file. But for
>> > transforming the file, the used XMLReader tries to download the dtd from
>> thw
>> > w3c website.
>> >
>> > Is it possible, to tell the xslt component, to configure the xml reader
>> to
>> > use local version (e.g. by using xml catalogs) or not to validate dtd's
>> at
>> > all?
>> >
>>
>> Hi
>>
>> You can use a custom uriResolver. Would that do the trick?
>> http://camel.apache.org/xslt
>>
>> > thanks
>> > Dirk
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> Red Hat, Inc.
>> FuseSource is now part of Red Hat
>> Email: [hidden email]
>> Web: http://fusesource.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen



--
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Loading...