Using URIResolver or using the Catalog to rewriteSystem

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Using URIResolver or using the Catalog to rewriteSystem

markus.sticker.epos

Hello Saxonica,

 

my task  is to write a Servlet to transform XML with XSLT.

The catalog will change on each different call.

But all the time I’ve got a file not found message.

 

This is my catalog:

<?xml version="1.0" ?>

<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.0//EN"  "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" >

  <!-- XML Combine -->

  <rewriteURI uriStartString="file:///xmldoc"          rewritePrefix="file:///O:/xmldoc"/>

  <!-- Toolchain -->

  <rewriteSystem systemIdStartString="o:///"           rewritePrefix="file:///O:/"/>

  <rewriteSystem systemIdStartString="O:///"           rewritePrefix="file:///O:/"/>

  <rewriteSystem systemIdStartString="file:///"        rewritePrefix="file:///O:/"/>

  <rewriteSystem systemIdStartString="file:///xmldoc"  rewritePrefix="file:///O:/xmldoc"/>

 <rewriteSystem systemIdStartString="file:/xmldoc"    rewritePrefix="file:///O:/xmldoc"/>

    <!--Start Serna -->

  <rewriteSystem systemIdStartString="/"               rewritePrefix="file:///O:/"/>

  <public publicId="-//W3C//DTD SVG 1.0//EN" uri="file:///O:/xmldoc/doctypes/svg/svg10.dtd"/>

  <public publicId="-//W3C//DTD SVG 1.1//EN" uri="file:///O:/xmldoc/doctypes/svg/svg11.dtd"/>             

</catalog>

 

This is my XML:

<?xml version="1.0"?>

<!DOCTYPE XMLBlock SYSTEM "/xmldoc/doctypes/XMLBlock/XMLBlock.dtd" []>

<XMLBlock>

<someText>Lorem ipsum dolor sit amet, consetetur ...</someText>

</XMLBlock>

 

This is a part of my source code:

  TransformerFactory tfactory = TransformerFactory.newInstance();

 

  // Does this factory support SAX features?

  if (tfactory.getFeature(SAXSource.FEATURE)) {

 

             // If so, we can safely cast.

             SAXTransformerFactory stfactory = ((SAXTransformerFactory) tfactory);

 

              // Create a Templates ContentHandler to handle parsing of the

              // stylesheet.

              javax.xml.transform.sax.TemplatesHandler templatesHandler;

              CatalogManager manager = new CatalogManager(“C:\\temp\\CatalogManager.properties”);

 

              String[] catalogs = { "file:///C:/temp/catalog_serna.xml" };

              // Create catalog resolver and set a catalog list.

             XMLCatalogResolver resolver = new XMLCatalogResolver();

             resolver.setPreferPublic(true);

             resolver.setCatalogList(catalogs);

 

             // Set the resolver on the parser.

 

             try {

                    templatesHandler = stfactory.newTemplatesHandler();

                    // Create an XMLReader and set its features.

                    XMLReader reader = new LexEv();

                    reader.setFeature("http://xml.org/sax/features/namespaces", true);

                    reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);

                    // Create a XMLFilter that modifies the stylesheet

                    XMLFilter filter = new ModifyStylesheetFilter();

                    filter.setParent(reader);

                    filter.setContentHandler(templatesHandler);

                    // Parse the stylesheet.

                    filter.parse(new InputSource(style));

                    Transformer transfromer = templates.newTransformer();

                   // transfromer.setURIResolver(uresolver);

                    // do the transformation

                    transfromer.transform(new StreamSource(source), result);

 

} catch ( ...

 

I also tried something like that:

                    EntityResolver eresolver = new CatalogResolver(manager);

                    URIResolver uresolver = new CatalogResolver(manager);

             And

reader.setEntityResolver(eresolver);                 

transfromer.setURIResolver(uresolver);

                    stfactory.setURIResolver(uresolver);

 

Maybe you can help me on my mistake.
Many thanks in advance.
Kind regards

Markus Sticker

 


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Using URIResolver or using the Catalog to rewriteSystem

Michael Kay
Some points:

(1) the Catalog resolver is not Saxonica’s product and we are often as mystified by it as anyone else.

(2) what exactly is the file not found message? Does it identify the file? Do you know (e.g. from a stack trace) which file is not found? 

(3) you’re using LexEv. Can you eliminate this as a possible cause? Do you still get problems if you aren’t using LexEv?

(4) looking at your code, I can’t see where “templates” comes from. I would expect to see “templates = templatesHandler.getTemplates()” somewhere.

(5) excluding the “I also tried” section, your code seems to create a Resolver and then doesn’t use it.

(6) you haven’t said what you are using the CatalogResolver for. What kind of URI are you trying to redirect? Stylesheet? Source document? XML external entity?

Michael Kay
Saxonica




On 16 Oct 2015, at 15:36, [hidden email] wrote:

Hello Saxonica,

 

my task  is to write a Servlet to transform XML with XSLT.

The catalog will change on each different call.

But all the time I’ve got a file not found message.

 

This is my catalog:

<?xml version="1.0" ?>

<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.0//EN"  "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" >

  <!-- XML Combine -->

  <rewriteURI uriStartString="file:///xmldoc"          rewritePrefix="file:///O:/xmldoc"/>

  <!-- Toolchain -->

  <rewriteSystem systemIdStartString="<a href="o:///" class="">o:///"           rewritePrefix="file:///O:/"/>

  <rewriteSystem systemIdStartString="<a href="O:///" class="">O:///"           rewritePrefix="file:///O:/"/>

  <rewriteSystem systemIdStartString="file:///"        rewritePrefix="file:///O:/"/>

  <rewriteSystem systemIdStartString="file:///xmldoc"  rewritePrefix="file:///O:/xmldoc"/>

 <rewriteSystem systemIdStartString="file:/xmldoc"    rewritePrefix="file:///O:/xmldoc"/>

    <!--Start Serna -->

  <rewriteSystem systemIdStartString="/"               rewritePrefix="file:///O:/"/>

  <public publicId="-//W3C//DTD SVG 1.0//EN" uri="file:///O:/xmldoc/doctypes/svg/svg10.dtd"/>

  <public publicId="-//W3C//DTD SVG 1.1//EN" uri="file:///O:/xmldoc/doctypes/svg/svg11.dtd"/>             

</catalog>

 

This is my XML:

<?xml version="1.0"?>

<!DOCTYPE XMLBlock SYSTEM "/xmldoc/doctypes/XMLBlock/XMLBlock.dtd" []>

<XMLBlock>

<someText>Lorem ipsum dolor sit amet, consetetur ...</someText>

</XMLBlock>

 

This is a part of my source code:

  TransformerFactory tfactory = TransformerFactory.newInstance();

 

  // Does this factory support SAX features?

  if (tfactory.getFeature(SAXSource.FEATURE)) {

 

             // If so, we can safely cast.

             SAXTransformerFactory stfactory = ((SAXTransformerFactory) tfactory);

 

              // Create a Templates ContentHandler to handle parsing of the

              // stylesheet.

              javax.xml.transform.sax.TemplatesHandler templatesHandler;

              CatalogManager manager = new CatalogManager(“C:<a href="smb://temp//" class="">\\temp\\CatalogManager.properties”);

 

              String[] catalogs = { "file:///C:/temp/catalog_serna.xml" };

              // Create catalog resolver and set a catalog list.

             XMLCatalogResolver resolver = new XMLCatalogResolver();

             resolver.setPreferPublic(true);

             resolver.setCatalogList(catalogs);

 

             // Set the resolver on the parser.

 

             try {

                    templatesHandler = stfactory.newTemplatesHandler();

                    // Create an XMLReader and set its features.

                    XMLReader reader = new LexEv();

                    reader.setFeature("http://xml.org/sax/features/namespaces", true);

                    reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);

                    // Create a XMLFilter that modifies the stylesheet

                    XMLFilter filter = new ModifyStylesheetFilter();

                    filter.setParent(reader);

                    filter.setContentHandler(templatesHandler);

                    // Parse the stylesheet.

                    filter.parse(new InputSource(style));

                    Transformer transfromer = templates.newTransformer();

                   // transfromer.setURIResolver(uresolver);

                    // do the transformation

                    transfromer.transform(new StreamSource(source), result);

 

} catch ( ...

 

I also tried something like that:

                    EntityResolver eresolver = new CatalogResolver(manager);

                    URIResolver uresolver = new CatalogResolver(manager);

             And

reader.setEntityResolver(eresolver);                 

transfromer.setURIResolver(uresolver);

                    stfactory.setURIResolver(uresolver);

 

Maybe you can help me on my mistake.
Many thanks in advance.
Kind regards

Markus Sticker

 

------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Using URIResolver or using the Catalog to rewriteSystem

markus.sticker.epos
Good Morning,

Thanks for your reply.
(1) & (6)
I use the xerces (xerces 2.11.0) to resolve the DTD URI:
    In the Document: <!DOCTYPE XMLBlock SYSTEM "/xmldoc/doctypes/XMLBlock/XMLBlock.dtd" []>
    Resolved Path:                            O:/xmldoc/doctypes/XMLBlock/XMLBlock.dtd

(2) This is the StackTrace:
java.io.FileNotFoundException: \xmldoc\doctypes\XMLBlock\XMLBlock.dtd (Das System kann den angegebenen Pfad nicht finden)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:138)
        at java.io.FileInputStream.<init>(FileInputStream.java:97)
        at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
        at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
        at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
        at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
        at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
        at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:404)
        at net.sf.saxon.event.Sender.send(Sender.java:214)
        at net.sf.saxon.event.Sender.send(Sender.java:50)
        at net.sf.saxon.Controller.transform(Controller.java:1611)
        at com.zf.swdoku.saxon9.SaxonServlet.apply(SaxonServlet.java:190)
        at com.zf.swdoku.saxon9.SaxonServlet.service(SaxonServlet.java:83)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
        at org.eclipse.jetty.server.Server.handle(Server.java:370)
        at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
        at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
        at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
        at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
        at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
        at java.lang.Thread.run(Thread.java:722)

Line 190: transfromer.transform(new StreamSource(source), result);

(3)
Yes, if got the same message when I used XMLReader reader = factory.newSAXParser().getXMLReader();

(4)
The TemplateHandler is created by this:
TransformerFactory    tfactory  = TransformerFactory.newInstance();
SAXTransformerFactory stfactory = ((SAXTransformerFactory) tfactory);
javax.xml.transform.sax.TemplatesHandler templatesHandler;
templatesHandler = stfactory.newTemplatesHandler();

(5)
All try out code has been removed
I use that currently:
CatalogManager manager   = new CatalogManager(propertyFile);
URIResolver    uresolver = new CatalogResolver(manager);
transfromer.setURIResolver(uresolver);

Thanks for your help
Kind regards

Markus



Von: Michael Kay [mailto:[hidden email]]
Gesendet: Freitag, 16. Oktober 2015 17:41
An: Mailing list for the SAXON XSLT and XQuery processor
Betreff: Re: [saxon] Using URIResolver or using the Catalog to rewriteSystem

Some points:

(1) the Catalog resolver is not Saxonica’s product and we are often as mystified by it as anyone else.

(2) what exactly is the file not found message? Does it identify the file? Do you know (e.g. from a stack trace) which file is not found? 

(3) you’re using LexEv. Can you eliminate this as a possible cause? Do you still get problems if you aren’t using LexEv?

(4) looking at your code, I can’t see where “templates” comes from. I would expect to see “templates = templatesHandler.getTemplates()” somewhere.

(5) excluding the “I also tried” section, your code seems to create a Resolver and then doesn’t use it.

(6) you haven’t said what you are using the CatalogResolver for. What kind of URI are you trying to redirect? Stylesheet? Source document? XML external entity?

Michael Kay
Saxonica




On 16 Oct 2015, at 15:36, [hidden email] wrote:

Hello Saxonica,
 
my task  is to write a Servlet to transform XML with XSLT.
The catalog will change on each different call.
But all the time I’ve got a file not found message.
 
This is my catalog:
<?xml version="1.0" ?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.0//EN"  "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" >
  <!-- XML Combine -->
  <rewriteURI uriStartString="file:///xmldoc"          rewritePrefix="file:///O:/xmldoc"/>
  <!-- Toolchain -->
  <rewriteSystem systemIdStartString="o:///"           rewritePrefix="file:///O:/"/>
  <rewriteSystem systemIdStartString="O:///"           rewritePrefix="file:///O:/"/>
  <rewriteSystem systemIdStartString="file:///"        rewritePrefix="file:///O:/"/>
  <rewriteSystem systemIdStartString="file:///xmldoc"  rewritePrefix="file:///O:/xmldoc"/>
 <rewriteSystem systemIdStartString="file:/xmldoc"    rewritePrefix="file:///O:/xmldoc"/>
    <!--Start Serna -->
  <rewriteSystem systemIdStartString="/"               rewritePrefix="file:///O:/"/>
  <public publicId="-//W3C//DTD SVG 1.0//EN" uri="file:///O:/xmldoc/doctypes/svg/svg10.dtd"/>
  <public publicId="-//W3C//DTD SVG 1.1//EN" uri="file:///O:/xmldoc/doctypes/svg/svg11.dtd"/>             
</catalog>
 
This is my XML:
<?xml version="1.0"?>
<!DOCTYPE XMLBlock SYSTEM "/xmldoc/doctypes/XMLBlock/XMLBlock.dtd" []>
<XMLBlock>
<someText>Lorem ipsum dolor sit amet, consetetur ...</someText>
</XMLBlock>
 
This is a part of my source code:
  TransformerFactory tfactory = TransformerFactory.newInstance();
 
  // Does this factory support SAX features?
  if (tfactory.getFeature(SAXSource.FEATURE)) {
 
             // If so, we can safely cast.
             SAXTransformerFactory stfactory = ((SAXTransformerFactory) tfactory);
 
              // Create a Templates ContentHandler to handle parsing of the
              // stylesheet.
              javax.xml.transform.sax.TemplatesHandler templatesHandler;
              CatalogManager manager = new CatalogManager(“C:\\temp\\CatalogManager.properties”);
 
              String[] catalogs = { "file:///C:/temp/catalog_serna.xml" };
              // Create catalog resolver and set a catalog list.
             XMLCatalogResolver resolver = new XMLCatalogResolver();
             resolver.setPreferPublic(true);
             resolver.setCatalogList(catalogs);
 
             // Set the resolver on the parser.
 
             try {
                    templatesHandler = stfactory.newTemplatesHandler();
                    // Create an XMLReader and set its features.
                    XMLReader reader = new LexEv();
                    reader.setFeature("http://xml.org/sax/features/namespaces", true);
                    reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
                    // Create a XMLFilter that modifies the stylesheet
                    XMLFilter filter = new ModifyStylesheetFilter();
                    filter.setParent(reader);
                    filter.setContentHandler(templatesHandler);
                    // Parse the stylesheet.
                    filter.parse(new InputSource(style));
                    Transformer transfromer = templates.newTransformer();
                   // transfromer.setURIResolver(uresolver);
                    // do the transformation
                    transfromer.transform(new StreamSource(source), result);
 
       } catch ( ...
 
I also tried something like that:
                    EntityResolver eresolver = new CatalogResolver(manager);
                    URIResolver uresolver = new CatalogResolver(manager);
             And
       reader.setEntityResolver(eresolver);                 
       transfromer.setURIResolver(uresolver);
                    stfactory.setURIResolver(uresolver);
 
Maybe you can help me on my mistake.
Many thanks in advance.
Kind regards
Markus Sticker


 
------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 

------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Using URIResolver or using the Catalog to rewriteSystem

Michael Kay
It’s failing (apparently) on accessing the DTD for the source document. There is no evidence that it’s attempting to use the catalog resolver for this purpose. In other words, the catalog resolver appears not to be set as the EntityResolver on the XMLReader being used to parse the source document.

I think you are probably creating the XMLReader yourself, rather than leaving Saxon to do it; in that case, calling setEntityResolver() on the XMLReader is your responsibility — Saxon isn’t going to modify the XMLReader you have created. A URIResolver is used only for resolving references at the XSLT level, e.g. the URI of documents accessed using the document() function; entities like DTDs are handled at a lower level by the XML parser itself.

There may be a conflict with LexEv here - I’m not sure where that fits into the picture. LexEv may want to set options on the XML parser itself.

Michael Kay
Saxonica

> On 20 Oct 2015, at 09:32, [hidden email] wrote:
>
> Good Morning,
>
> Thanks for your reply.
> (1) & (6)
> I use the xerces (xerces 2.11.0) to resolve the DTD URI:
>    In the Document: <!DOCTYPE XMLBlock SYSTEM "/xmldoc/doctypes/XMLBlock/XMLBlock.dtd" []>
>    Resolved Path:                            O:/xmldoc/doctypes/XMLBlock/XMLBlock.dtd
>
> (2) This is the StackTrace:
> java.io.FileNotFoundException: \xmldoc\doctypes\XMLBlock\XMLBlock.dtd (Das System kann den angegebenen Pfad nicht finden)
>        at java.io.FileInputStream.open(Native Method)
>        at java.io.FileInputStream.<init>(FileInputStream.java:138)
>        at java.io.FileInputStream.<init>(FileInputStream.java:97)
>        at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
>        at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
>        at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
>        at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
>        at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
>        at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
>        at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
>        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
>        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
>        at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:404)
>        at net.sf.saxon.event.Sender.send(Sender.java:214)
>        at net.sf.saxon.event.Sender.send(Sender.java:50)
>        at net.sf.saxon.Controller.transform(Controller.java:1611)
>        at com.zf.swdoku.saxon9.SaxonServlet.apply(SaxonServlet.java:190)
>        at com.zf.swdoku.saxon9.SaxonServlet.service(SaxonServlet.java:83)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
>        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
>        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
>        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533)
>        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
>        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
>        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
>        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
>        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
>        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
>        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
>        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
>        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
>        at org.eclipse.jetty.server.Server.handle(Server.java:370)
>        at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
>        at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
>        at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
>        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
>        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
>        at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
>        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
>        at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
>        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
>        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
>        at java.lang.Thread.run(Thread.java:722)
>
> Line 190: transfromer.transform(new StreamSource(source), result);
>
> (3)
> Yes, if got the same message when I used XMLReader reader = factory.newSAXParser().getXMLReader();
>
> (4)
> The TemplateHandler is created by this:
> TransformerFactory    tfactory  = TransformerFactory.newInstance();
> SAXTransformerFactory stfactory = ((SAXTransformerFactory) tfactory);
> javax.xml.transform.sax.TemplatesHandler templatesHandler;
> templatesHandler = stfactory.newTemplatesHandler();
>
> (5)
> All try out code has been removed
> I use that currently:
> CatalogManager manager   = new CatalogManager(propertyFile);
> URIResolver    uresolver = new CatalogResolver(manager);
> transfromer.setURIResolver(uresolver);
>
> Thanks for your help
> Kind regards
>
> Markus
>
>
>
> Von: Michael Kay [mailto:[hidden email]]
> Gesendet: Freitag, 16. Oktober 2015 17:41
> An: Mailing list for the SAXON XSLT and XQuery processor
> Betreff: Re: [saxon] Using URIResolver or using the Catalog to rewriteSystem
>
> Some points:
>
> (1) the Catalog resolver is not Saxonica’s product and we are often as mystified by it as anyone else.
>
> (2) what exactly is the file not found message? Does it identify the file? Do you know (e.g. from a stack trace) which file is not found?
>
> (3) you’re using LexEv. Can you eliminate this as a possible cause? Do you still get problems if you aren’t using LexEv?
>
> (4) looking at your code, I can’t see where “templates” comes from. I would expect to see “templates = templatesHandler.getTemplates()” somewhere.
>
> (5) excluding the “I also tried” section, your code seems to create a Resolver and then doesn’t use it.
>
> (6) you haven’t said what you are using the CatalogResolver for. What kind of URI are you trying to redirect? Stylesheet? Source document? XML external entity?
>
> Michael Kay
> Saxonica
>
>
>
>
> On 16 Oct 2015, at 15:36, [hidden email] wrote:
>
> Hello Saxonica,
>  
> my task  is to write a Servlet to transform XML with XSLT.
> The catalog will change on each different call.
> But all the time I’ve got a file not found message.
>  
> This is my catalog:
> <?xml version="1.0" ?>
> <!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.0//EN"  "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" >
>   <!-- XML Combine -->
>   <rewriteURI uriStartString="file:///xmldoc"          rewritePrefix="file:///O:/xmldoc"/>
>   <!-- Toolchain -->
>   <rewriteSystem systemIdStartString="o:///"           rewritePrefix="file:///O:/"/>
>   <rewriteSystem systemIdStartString="O:///"           rewritePrefix="file:///O:/"/>
>   <rewriteSystem systemIdStartString="file:///"        rewritePrefix="file:///O:/"/>
>   <rewriteSystem systemIdStartString="file:///xmldoc"  rewritePrefix="file:///O:/xmldoc"/>
>  <rewriteSystem systemIdStartString="file:/xmldoc"    rewritePrefix="file:///O:/xmldoc"/>
>     <!--Start Serna -->
>   <rewriteSystem systemIdStartString="/"               rewritePrefix="file:///O:/"/>
>   <public publicId="-//W3C//DTD SVG 1.0//EN" uri="file:///O:/xmldoc/doctypes/svg/svg10.dtd"/>
>   <public publicId="-//W3C//DTD SVG 1.1//EN" uri="file:///O:/xmldoc/doctypes/svg/svg11.dtd"/>              
> </catalog>
>  
> This is my XML:
> <?xml version="1.0"?>
> <!DOCTYPE XMLBlock SYSTEM "/xmldoc/doctypes/XMLBlock/XMLBlock.dtd" []>
> <XMLBlock>
> <someText>Lorem ipsum dolor sit amet, consetetur ...</someText>
> </XMLBlock>
>  
> This is a part of my source code:
>   TransformerFactory tfactory = TransformerFactory.newInstance();
>  
>   // Does this factory support SAX features?
>   if (tfactory.getFeature(SAXSource.FEATURE)) {
>  
>              // If so, we can safely cast.
>              SAXTransformerFactory stfactory = ((SAXTransformerFactory) tfactory);
>  
>               // Create a Templates ContentHandler to handle parsing of the
>               // stylesheet.
>               javax.xml.transform.sax.TemplatesHandler templatesHandler;
>               CatalogManager manager = new CatalogManager(“C:\\temp\\CatalogManager.properties”);
>  
>               String[] catalogs = { "file:///C:/temp/catalog_serna.xml" };
>               // Create catalog resolver and set a catalog list.
>              XMLCatalogResolver resolver = new XMLCatalogResolver();
>              resolver.setPreferPublic(true);
>              resolver.setCatalogList(catalogs);
>  
>              // Set the resolver on the parser.
>  
>              try {
>                     templatesHandler = stfactory.newTemplatesHandler();
>                     // Create an XMLReader and set its features.
>                     XMLReader reader = new LexEv();
>                     reader.setFeature("http://xml.org/sax/features/namespaces", true);
>                     reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
>                     // Create a XMLFilter that modifies the stylesheet
>                     XMLFilter filter = new ModifyStylesheetFilter();
>                     filter.setParent(reader);
>                     filter.setContentHandler(templatesHandler);
>                     // Parse the stylesheet.
>                     filter.parse(new InputSource(style));
>                     Transformer transfromer = templates.newTransformer();
>                    // transfromer.setURIResolver(uresolver);
>                     // do the transformation
>                     transfromer.transform(new StreamSource(source), result);
>  
>       } catch ( ...
>  
> I also tried something like that:
>                     EntityResolver eresolver = new CatalogResolver(manager);
>                     URIResolver uresolver = new CatalogResolver(manager);
>              And
>       reader.setEntityResolver(eresolver);                  
>       transfromer.setURIResolver(uresolver);
>                     stfactory.setURIResolver(uresolver);
>  
> Maybe you can help me on my mistake.
> Many thanks in advance.
> Kind regards
> Markus Sticker
>
>
>  
> ------------------------------------------------------------------------------
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 
>
> ------------------------------------------------------------------------------
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Using URIResolver or using the Catalog to rewriteSystem

Andrew Welch

Hi,

I'm afraid free support isnt available as I don't have time any more.

The day job, a small child, a new house etc...

On 20 Oct 2015 10:16, "Michael Kay" <[hidden email]> wrote:
It’s failing (apparently) on accessing the DTD for the source document. There is no evidence that it’s attempting to use the catalog resolver for this purpose. In other words, the catalog resolver appears not to be set as the EntityResolver on the XMLReader being used to parse the source document.

I think you are probably creating the XMLReader yourself, rather than leaving Saxon to do it; in that case, calling setEntityResolver() on the XMLReader is your responsibility — Saxon isn’t going to modify the XMLReader you have created. A URIResolver is used only for resolving references at the XSLT level, e.g. the URI of documents accessed using the document() function; entities like DTDs are handled at a lower level by the XML parser itself.

There may be a conflict with LexEv here - I’m not sure where that fits into the picture. LexEv may want to set options on the XML parser itself.

Michael Kay
Saxonica

> On 20 Oct 2015, at 09:32, [hidden email] wrote:
>
> Good Morning,
>
> Thanks for your reply.
> (1) & (6)
> I use the xerces (xerces 2.11.0) to resolve the DTD URI:
>    In the Document: <!DOCTYPE XMLBlock SYSTEM "/xmldoc/doctypes/XMLBlock/XMLBlock.dtd" []>
>    Resolved Path:                            O:/xmldoc/doctypes/XMLBlock/XMLBlock.dtd
>
> (2) This is the StackTrace:
> java.io.FileNotFoundException: \xmldoc\doctypes\XMLBlock\XMLBlock.dtd (Das System kann den angegebenen Pfad nicht finden)
>        at java.io.FileInputStream.open(Native Method)
>        at java.io.FileInputStream.<init>(FileInputStream.java:138)
>        at java.io.FileInputStream.<init>(FileInputStream.java:97)
>        at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
>        at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
>        at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
>        at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
>        at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
>        at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
>        at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
>        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
>        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
>        at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:404)
>        at net.sf.saxon.event.Sender.send(Sender.java:214)
>        at net.sf.saxon.event.Sender.send(Sender.java:50)
>        at net.sf.saxon.Controller.transform(Controller.java:1611)
>        at com.zf.swdoku.saxon9.SaxonServlet.apply(SaxonServlet.java:190)
>        at com.zf.swdoku.saxon9.SaxonServlet.service(SaxonServlet.java:83)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
>        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
>        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
>        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533)
>        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
>        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
>        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
>        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
>        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
>        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
>        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
>        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
>        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
>        at org.eclipse.jetty.server.Server.handle(Server.java:370)
>        at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
>        at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
>        at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
>        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
>        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
>        at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
>        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
>        at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
>        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
>        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
>        at java.lang.Thread.run(Thread.java:722)
>
> Line 190: transfromer.transform(new StreamSource(source), result);
>
> (3)
> Yes, if got the same message when I used XMLReader reader = factory.newSAXParser().getXMLReader();
>
> (4)
> The TemplateHandler is created by this:
> TransformerFactory    tfactory  = TransformerFactory.newInstance();
> SAXTransformerFactory stfactory = ((SAXTransformerFactory) tfactory);
> javax.xml.transform.sax.TemplatesHandler templatesHandler;
> templatesHandler = stfactory.newTemplatesHandler();
>
> (5)
> All try out code has been removed
> I use that currently:
> CatalogManager manager   = new CatalogManager(propertyFile);
> URIResolver    uresolver = new CatalogResolver(manager);
> transfromer.setURIResolver(uresolver);
>
> Thanks for your help
> Kind regards
>
> Markus
>
>
>
> Von: Michael Kay [mailto:[hidden email]]
> Gesendet: Freitag, 16. Oktober 2015 17:41
> An: Mailing list for the SAXON XSLT and XQuery processor
> Betreff: Re: [saxon] Using URIResolver or using the Catalog to rewriteSystem
>
> Some points:
>
> (1) the Catalog resolver is not Saxonica’s product and we are often as mystified by it as anyone else.
>
> (2) what exactly is the file not found message? Does it identify the file? Do you know (e.g. from a stack trace) which file is not found?
>
> (3) you’re using LexEv. Can you eliminate this as a possible cause? Do you still get problems if you aren’t using LexEv?
>
> (4) looking at your code, I can’t see where “templates” comes from. I would expect to see “templates = templatesHandler.getTemplates()” somewhere.
>
> (5) excluding the “I also tried” section, your code seems to create a Resolver and then doesn’t use it.
>
> (6) you haven’t said what you are using the CatalogResolver for. What kind of URI are you trying to redirect? Stylesheet? Source document? XML external entity?
>
> Michael Kay
> Saxonica
>
>
>
>
> On 16 Oct 2015, at 15:36, [hidden email] wrote:
>
> Hello Saxonica,
>
> my task  is to write a Servlet to transform XML with XSLT.
> The catalog will change on each different call.
> But all the time I’ve got a file not found message.
>
> This is my catalog:
> <?xml version="1.0" ?>
> <!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.0//EN"  "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" >
>   <!-- XML Combine -->
>   <rewriteURI uriStartString="file:///xmldoc"          rewritePrefix="file:///O:/xmldoc"/>
>   <!-- Toolchain -->
>   <rewriteSystem systemIdStartString="o:///"           rewritePrefix="file:///O:/"/>
>   <rewriteSystem systemIdStartString="O:///"           rewritePrefix="file:///O:/"/>
>   <rewriteSystem systemIdStartString="file:///"        rewritePrefix="file:///O:/"/>
>   <rewriteSystem systemIdStartString="file:///xmldoc"  rewritePrefix="file:///O:/xmldoc"/>
>  <rewriteSystem systemIdStartString="file:/xmldoc"    rewritePrefix="file:///O:/xmldoc"/>
>     <!--Start Serna -->
>   <rewriteSystem systemIdStartString="/"               rewritePrefix="file:///O:/"/>
>   <public publicId="-//W3C//DTD SVG 1.0//EN" uri="file:///O:/xmldoc/doctypes/svg/svg10.dtd"/>
>   <public publicId="-//W3C//DTD SVG 1.1//EN" uri="file:///O:/xmldoc/doctypes/svg/svg11.dtd"/>
> </catalog>
>
> This is my XML:
> <?xml version="1.0"?>
> <!DOCTYPE XMLBlock SYSTEM "/xmldoc/doctypes/XMLBlock/XMLBlock.dtd" []>
> <XMLBlock>
> <someText>Lorem ipsum dolor sit amet, consetetur ...</someText>
> </XMLBlock>
>
> This is a part of my source code:
>   TransformerFactory tfactory = TransformerFactory.newInstance();
>
>   // Does this factory support SAX features?
>   if (tfactory.getFeature(SAXSource.FEATURE)) {
>
>              // If so, we can safely cast.
>              SAXTransformerFactory stfactory = ((SAXTransformerFactory) tfactory);
>
>               // Create a Templates ContentHandler to handle parsing of the
>               // stylesheet.
>               javax.xml.transform.sax.TemplatesHandler templatesHandler;
>               CatalogManager manager = new CatalogManager(“C:\\temp\\CatalogManager.properties”);
>
>               String[] catalogs = { "file:///C:/temp/catalog_serna.xml" };
>               // Create catalog resolver and set a catalog list.
>              XMLCatalogResolver resolver = new XMLCatalogResolver();
>              resolver.setPreferPublic(true);
>              resolver.setCatalogList(catalogs);
>
>              // Set the resolver on the parser.
>
>              try {
>                     templatesHandler = stfactory.newTemplatesHandler();
>                     // Create an XMLReader and set its features.
>                     XMLReader reader = new LexEv();
>                     reader.setFeature("http://xml.org/sax/features/namespaces", true);
>                     reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
>                     // Create a XMLFilter that modifies the stylesheet
>                     XMLFilter filter = new ModifyStylesheetFilter();
>                     filter.setParent(reader);
>                     filter.setContentHandler(templatesHandler);
>                     // Parse the stylesheet.
>                     filter.parse(new InputSource(style));
>                     Transformer transfromer = templates.newTransformer();
>                    // transfromer.setURIResolver(uresolver);
>                     // do the transformation
>                     transfromer.transform(new StreamSource(source), result);
>
>       } catch ( ...
>
> I also tried something like that:
>                     EntityResolver eresolver = new CatalogResolver(manager);
>                     URIResolver uresolver = new CatalogResolver(manager);
>              And
>       reader.setEntityResolver(eresolver);
>       transfromer.setURIResolver(uresolver);
>                     stfactory.setURIResolver(uresolver);
>
> Maybe you can help me on my mistake.
> Many thanks in advance.
> Kind regards
> Markus Sticker
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
> ------------------------------------------------------------------------------
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help

------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Using URIResolver or using the Catalog to rewriteSystem

markus.sticker.epos
Hi,
ok. No problem. I will try it on my own.
But maybe you have even a sample or know a sample on the web.
Kind regards

Markus


Von: Andrew Welch [mailto:[hidden email]]
Gesendet: Dienstag, 20. Oktober 2015 15:05
An: Mailing list for the SAXON XSLT and XQuery processor
Betreff: Re: [saxon] Using URIResolver or using the Catalog to rewriteSystem

Hi,
I'm afraid free support isnt available as I don't have time any more.
The day job, a small child, a new house etc...
On 20 Oct 2015 10:16, "Michael Kay" <[hidden email]> wrote:
It’s failing (apparently) on accessing the DTD for the source document. There is no evidence that it’s attempting to use the catalog resolver for this purpose. In other words, the catalog resolver appears not to be set as the EntityResolver on the XMLReader being used to parse the source document.

I think you are probably creating the XMLReader yourself, rather than leaving Saxon to do it; in that case, calling setEntityResolver() on the XMLReader is your responsibility — Saxon isn’t going to modify the XMLReader you have created. A URIResolver is used only for resolving references at the XSLT level, e.g. the URI of documents accessed using the document() function; entities like DTDs are handled at a lower level by the XML parser itself.

There may be a conflict with LexEv here - I’m not sure where that fits into the picture. LexEv may want to set options on the XML parser itself.

Michael Kay
Saxonica

> On 20 Oct 2015, at 09:32, [hidden email] wrote:
>
> Good Morning,
>
> Thanks for your reply.
> (1) & (6)
> I use the xerces (xerces 2.11.0) to resolve the DTD URI:
>    In the Document: <!DOCTYPE XMLBlock SYSTEM "/xmldoc/doctypes/XMLBlock/XMLBlock.dtd" []>
>    Resolved Path:                            O:/xmldoc/doctypes/XMLBlock/XMLBlock.dtd
>
> (2) This is the StackTrace:
> java.io.FileNotFoundException: \xmldoc\doctypes\XMLBlock\XMLBlock.dtd (Das System kann den angegebenen Pfad nicht finden)
>        at java.io.FileInputStream.open(Native Method)
>        at java.io.FileInputStream.<init>(FileInputStream.java:138)
>        at java.io.FileInputStream.<init>(FileInputStream.java:97)
>        at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
>        at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
>        at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
>        at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
>        at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
>        at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
>        at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
>        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
>        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
>        at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:404)
>        at net.sf.saxon.event.Sender.send(Sender.java:214)
>        at net.sf.saxon.event.Sender.send(Sender.java:50)
>        at net.sf.saxon.Controller.transform(Controller.java:1611)
>        at com.zf.swdoku.saxon9.SaxonServlet.apply(SaxonServlet.java:190)
>        at com.zf.swdoku.saxon9.SaxonServlet.service(SaxonServlet.java:83)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
>        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
>        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
>        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533)
>        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
>        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
>        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
>        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
>        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
>        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
>        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
>        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
>        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
>        at org.eclipse.jetty.server.Server.handle(Server.java:370)
>        at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
>        at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
>        at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
>        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
>        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
>        at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
>        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
>        at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
>        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
>        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
>        at java.lang.Thread.run(Thread.java:722)
>
> Line 190: transfromer.transform(new StreamSource(source), result);
>
> (3)
> Yes, if got the same message when I used XMLReader reader = factory.newSAXParser().getXMLReader();
>
> (4)
> The TemplateHandler is created by this:
> TransformerFactory    tfactory  = TransformerFactory.newInstance();
> SAXTransformerFactory stfactory = ((SAXTransformerFactory) tfactory);
> javax.xml.transform.sax.TemplatesHandler templatesHandler;
> templatesHandler = stfactory.newTemplatesHandler();
>
> (5)
> All try out code has been removed
> I use that currently:
> CatalogManager manager   = new CatalogManager(propertyFile);
> URIResolver    uresolver = new CatalogResolver(manager);
> transfromer.setURIResolver(uresolver);
>
> Thanks for your help
> Kind regards
>
> Markus
>
>
>
> Von: Michael Kay [mailto:[hidden email]]
> Gesendet: Freitag, 16. Oktober 2015 17:41
> An: Mailing list for the SAXON XSLT and XQuery processor
> Betreff: Re: [saxon] Using URIResolver or using the Catalog to rewriteSystem
>
> Some points:
>
> (1) the Catalog resolver is not Saxonica’s product and we are often as mystified by it as anyone else.
>
> (2) what exactly is the file not found message? Does it identify the file? Do you know (e.g. from a stack trace) which file is not found?
>
> (3) you’re using LexEv. Can you eliminate this as a possible cause? Do you still get problems if you aren’t using LexEv?
>
> (4) looking at your code, I can’t see where “templates” comes from. I would expect to see “templates = templatesHandler.getTemplates()” somewhere.
>
> (5) excluding the “I also tried” section, your code seems to create a Resolver and then doesn’t use it.
>
> (6) you haven’t said what you are using the CatalogResolver for. What kind of URI are you trying to redirect? Stylesheet? Source document? XML external entity?
>
> Michael Kay
> Saxonica
>
>
>
>
> On 16 Oct 2015, at 15:36, [hidden email] wrote:
>
> Hello Saxonica,
>
> my task  is to write a Servlet to transform XML with XSLT.
> The catalog will change on each different call.
> But all the time I’ve got a file not found message.
>
> This is my catalog:
> <?xml version="1.0" ?>
> <!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.0//EN"  "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" >
>   <!-- XML Combine -->
>   <rewriteURI uriStartString="file:///xmldoc"          rewritePrefix="file:///O:/xmldoc"/>
>   <!-- Toolchain -->
>   <rewriteSystem systemIdStartString="o:///"           rewritePrefix="file:///O:/"/>
>   <rewriteSystem systemIdStartString="O:///"           rewritePrefix="file:///O:/"/>
>   <rewriteSystem systemIdStartString="file:///"        rewritePrefix="file:///O:/"/>
>   <rewriteSystem systemIdStartString="file:///xmldoc"  rewritePrefix="file:///O:/xmldoc"/>
>  <rewriteSystem systemIdStartString="file:/xmldoc"    rewritePrefix="file:///O:/xmldoc"/>
>     <!--Start Serna -->
>   <rewriteSystem systemIdStartString="/"               rewritePrefix="file:///O:/"/>
>   <public publicId="-//W3C//DTD SVG 1.0//EN" uri="file:///O:/xmldoc/doctypes/svg/svg10.dtd"/>
>   <public publicId="-//W3C//DTD SVG 1.1//EN" uri="file:///O:/xmldoc/doctypes/svg/svg11.dtd"/>
> </catalog>
>
> This is my XML:
> <?xml version="1.0"?>
> <!DOCTYPE XMLBlock SYSTEM "/xmldoc/doctypes/XMLBlock/XMLBlock.dtd" []>
> <XMLBlock>
> <someText>Lorem ipsum dolor sit amet, consetetur ...</someText>
> </XMLBlock>
>
> This is a part of my source code:
>   TransformerFactory tfactory = TransformerFactory.newInstance();
>
>   // Does this factory support SAX features?
>   if (tfactory.getFeature(SAXSource.FEATURE)) {
>
>              // If so, we can safely cast.
>              SAXTransformerFactory stfactory = ((SAXTransformerFactory) tfactory);
>
>               // Create a Templates ContentHandler to handle parsing of the
>               // stylesheet.
>               javax.xml.transform.sax.TemplatesHandler templatesHandler;
>               CatalogManager manager = new CatalogManager(“C:\\temp\\CatalogManager.properties”);
>
>               String[] catalogs = { "file:///C:/temp/catalog_serna.xml" };
>               // Create catalog resolver and set a catalog list.
>              XMLCatalogResolver resolver = new XMLCatalogResolver();
>              resolver.setPreferPublic(true);
>              resolver.setCatalogList(catalogs);
>
>              // Set the resolver on the parser.
>
>              try {
>                     templatesHandler = stfactory.newTemplatesHandler();
>                     // Create an XMLReader and set its features.
>                     XMLReader reader = new LexEv();
>                     reader.setFeature("http://xml.org/sax/features/namespaces", true);
>                     reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
>                     // Create a XMLFilter that modifies the stylesheet
>                     XMLFilter filter = new ModifyStylesheetFilter();
>                     filter.setParent(reader);
>                     filter.setContentHandler(templatesHandler);
>                     // Parse the stylesheet.
>                     filter.parse(new InputSource(style));
>                     Transformer transfromer = templates.newTransformer();
>                    // transfromer.setURIResolver(uresolver);
>                     // do the transformation
>                     transfromer.transform(new StreamSource(source), result);
>
>       } catch ( ...
>
> I also tried something like that:
>                     EntityResolver eresolver = new CatalogResolver(manager);
>                     URIResolver uresolver = new CatalogResolver(manager);
>              And
>       reader.setEntityResolver(eresolver);
>       transfromer.setURIResolver(uresolver);
>                     stfactory.setURIResolver(uresolver);
>
> Maybe you can help me on my mistake.
> Many thanks in advance.
> Kind regards
> Markus Sticker
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
> ------------------------------------------------------------------------------
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help