[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xerces-j-dev
Subject:    Re: Entity resolving problem in Docbook
From:       Mohammed Navas ck <navas () pitsolutions ! com>
Date:       2008-06-18 4:54:20
Message-ID: 4858922C.7080605 () pitsolutions ! com
[Download RAW message or body]

Michael Glavassevich wrote:
> 
> Hi Mohammed,
> 
Thanks Michael for your reply.
> 
> 
> You haven't said much about your actual code but I'm guessing you're 
> setting a URIResolver (which happens to also implement EntityResolver) 
> on the TransformerFactory and expecting that it's just magically going 
> to be set on parser instances. I don't believe Xalan does that. Should 
> probably be doing it explicitly anyway by providing a SAXSource to the 
> TransformerFactory with the EntityResolver already set on the XMLReader.
> 
I am using a separate class named *SourceResolver* to resolve the entity 
and relative path of xsl:include .this class implements URIResolver as 
you said and it also implements the EntityResolver .The URIResolver's 
method resolve is called to resolve the relative path in xsl:include, 
but it's not called on entity path .Then I use the resolveEntity method 
in EntityResolver .But it is not getting called at the time of entity 
path encounters.


I am using SAXTransformerFactory instead of TransformerFactory and I 
have set the URIResolver to this as my class *SourceResolver

*SourceResolver uriResolver = new SourceResolver(this); 
SAXTransformerFactory tf = 
(SAXTransformerFactory)TransformerFactory.newInstance();
tf.setURIResolver(uriResolver);

and the XMLReader is set with a catalogResolver as bellow.

XMLReader xmlReader = XMLReaderFactory.createXMLReader();
CatalogResolver catalogResolver = new CatalogResolver();
xmlReader.setEntityResolver(catalogResolver);
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", 
true);

This is my current situation

Best Regards
Navas
> 
> 
> As for your issues with using the EntityResolver, please note that "if 
> the system identifier is a URL, the SAX parser must resolve it fully 
> before reporting it to the application" [1]. So an absolute URL will 
> always be reported to the resolveEntity() method.
> 
> Thanks.
> 
> [1] 
> http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/EntityResolver.html#resolveEntity(java.lang.String,%20java.lang.String) \
>  <http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/EntityResolver.html#resolveEntity%28java.lang.String,%20java.lang.String%29>
>  
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
> 
> Mohammed Navas ck <navas@pitsolutions.com> wrote on 06/16/2008 
> 07:12:43 AM:
> 
> > Mohammed Navas ck wrote:
> > > Dear All
> > > 
> > > I am working on docbook integration into my application. In that I
> > > have a file that include a entity file in a xsl file which is 
> included
> > > in another xsl file as follows
> > > 
> > > <!DOCTYPE xsl:stylesheet [
> > > <!ENTITY % common.entities SYSTEM "../common/entities.ent">
> > > %common.entities;
> > > ]>
> > > 
> > > when I tried with absolute path instead of the relative path it works
> > > fine
> > > but I want to use the relative path itself
> > > 
> > > I have replaced the code bellow
> > > 
> > > <!ENTITY % common.entities SYSTEM "../common/entities.ent">
> > > %common.entities;
> > > 
> > > with the content of entities.ent file it also worked
> > > 
> > > So I think it has some problem with the entity resolver
> > > 
> > > 
> > > Using a URIResolver the path of xsl files are getting resolved but I
> > > can't resolve the entity file path .
> > > It throws an error like IO Exception file-name.xsl(the entity file
> > > included file)
> > 
> > My resolver() written is working but entityResolver() is not getting 
> called
> > Any body have why it is so
> > 
> > > Is there anybody who have faced this problem?
> > > 
> > > I tried to resolve this by using catalog
> > > for the I have added following line to catalog
> > > <system systemId="common/entities.ent"          
> > > uri="file:///src/realms/docbook/data-repo/data/docbook-xsl-1.73.
> > 2/common/entities.ent"
> > > />
> > > but it still throws the IO Exception
> > > 
> > > Thanks in advance
> > > 
> > > 
> > > Regards
> > > Navas
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > For additional commands, e-mail: j-users-help@xerces.apache.org
> > > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-users-help@xerces.apache.org
> 
> ------------------------------------------------------------------------
> 
> No virus found in this incoming message.
> Checked by AVG. 
> Version: 7.5.524 / Virus Database: 270.4.0/1506 - Release Date: 6/17/2008 4:30 PM
> 


[Attachment #3 (text/html)]

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Michael Glavassevich wrote:
<blockquote
 cite="mid:OFC9395D6E.14ED2551-ON8525746A.0056954B-8525746A.0057AE4F@ca.ibm.com"
 type="cite">
  <p><tt>Hi Mohammed,</tt><br>
  </p>
</blockquote>
Thanks Michael for your reply.<br>
<blockquote
 cite="mid:OFC9395D6E.14ED2551-ON8525746A.0056954B-8525746A.0057AE4F@ca.ibm.com"
 type="cite">
  <p><br>
  <tt>You haven't said much about your actual code but I'm guessing
you're setting a URIResolver (which happens to also implement
EntityResolver) on the TransformerFactory and expecting that it's just
magically going to be set on parser instances. I don't believe Xalan
does that. Should probably be doing it explicitly anyway by providing a
SAXSource to the TransformerFactory with the EntityResolver already set
on the XMLReader.</tt><br>
  </p>
</blockquote>
I am using<tt> a separate class named <b>SourceResolver</b> to resolve
the entity and relative path of xsl:include .this class implements
URIResolver as you said and it also implements the EntityResolver .The \
</tt><tt>URIResolver's method resolve is called to resolve the relative path in \
xsl:include, but it's not called on entity path .Then I use the resolveEntity method
in EntityResolver .But it is not getting called at the time of entity
path encounters.<br>
<br>
<br>
I am using </tt><tt>SAXTransformerFactory instead of </tt><tt>TransformerFactory
and</tt><tt> I have set the URIResolver to this as my class \
</tt><tt><b>SourceResolver<br> <br>
</b>SourceResolver uriResolver = new SourceResolver(this);&nbsp;</tt><br>
<tt>SAXTransformerFactory tf =
(SAXTransformerFactory)TransformerFactory.newInstance();<br>
tf.setURIResolver(uriResolver);<br>
<br>
and the XMLReader is set with a catalogResolver as bellow.<br>
<br>
XMLReader xmlReader = XMLReaderFactory.createXMLReader();<br>
CatalogResolver catalogResolver = new CatalogResolver();<br>
xmlReader.setEntityResolver(catalogResolver);<br>
xmlReader.setFeature(<a class="moz-txt-link-rfc2396E" \
href="http://xml.org/sax/features/namespace-prefixes">"http://xml.org/sax/features/namespace-prefixes"</a>,
 true);<br>
<br>
This is my current situation <br>
<br>
Best Regards <br>
Navas<br>
</tt>
<blockquote
 cite="mid:OFC9395D6E.14ED2551-ON8525746A.0056954B-8525746A.0057AE4F@ca.ibm.com"
 type="cite">
  <p><br>
  <tt>As for your issues with using the EntityResolver, please note
that "</tt><tt>if the system identifier is a URL, the SAX parser must
resolve it fully before reporting it to the application" [1]. So an
absolute URL will always be reported to the resolveEntity() method.</tt><br>
  <br>
  <tt>Thanks.</tt><br>
  <br>
  <tt>[1] </tt><tt><a moz-do-not-send="true"
 href="http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/EntityResolver.html \
#resolveEntity%28java.lang.String,%20java.lang.String%29">http://xerces.apache.org/xer \
ces2-j/javadocs/api/org/xml/sax/EntityResolver.html#resolveEntity(java.lang.String,%20java.lang.String)</a></tt><br>
  <br>
  <tt>Michael Glavassevich<br>
XML Parser Development<br>
IBM Toronto Lab<br>
E-mail: <a class="moz-txt-link-abbreviated" \
href="mailto:mrglavas@ca.ibm.com">mrglavas@ca.ibm.com</a></tt><br>  <tt>E-mail: <a \
class="moz-txt-link-abbreviated" \
href="mailto:mrglavas@apache.org">mrglavas@apache.org</a></tt><br>  <br>
  <tt>Mohammed Navas ck <a class="moz-txt-link-rfc2396E" \
href="mailto:navas@pitsolutions.com">&lt;navas@pitsolutions.com&gt;</a> wrote on \
06/16/2008 07:12:43 AM:<br>  <br>
&gt; Mohammed Navas ck wrote:<br>
&gt; &gt; Dear All<br>
&gt; &gt;<br>
&gt; &gt; I am working on docbook integration into my application. In
that I <br>
&gt; &gt; have a file that include a entity file in a xsl file which is
included <br>
&gt; &gt; in another xsl file as follows<br>
&gt; &gt;<br>
&gt; &gt; &lt;!DOCTYPE xsl:stylesheet [<br>
&gt; &gt; &lt;!ENTITY % common.entities SYSTEM
"../common/entities.ent"&gt;<br>
&gt; &gt; %common.entities;<br>
&gt; &gt; ]&gt;<br>
&gt; &gt;<br>
&gt; &gt; when I tried with absolute path instead of the relative path
it works <br>
&gt; &gt; fine<br>
&gt; &gt; but I want to use the relative path itself<br>
&gt; &gt;<br>
&gt; &gt; I have replaced the code bellow<br>
&gt; &gt;<br>
&gt; &gt; &lt;!ENTITY % common.entities SYSTEM
"../common/entities.ent"&gt;<br>
&gt; &gt; %common.entities;<br>
&gt; &gt;<br>
&gt; &gt; with the content of entities.ent file it also worked<br>
&gt; &gt;<br>
&gt; &gt; So I think it has some problem with the entity resolver<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Using a URIResolver the path of xsl files are getting
resolved but I <br>
&gt; &gt; can't resolve the entity file path .<br>
&gt; &gt; It throws an error like IO Exception file-name.xsl(the entity
file <br>
&gt; &gt; included file)<br>
&gt; <br>
&gt; My resolver() written is working but entityResolver() is not
getting called<br>
&gt; Any body have why it is so<br>
&gt; <br>
&gt; &gt; Is there anybody who have faced this problem?<br>
&gt; &gt;<br>
&gt; &gt; I tried to resolve this by using catalog<br>
&gt; &gt; for the I have added following line to catalog<br>
&gt; &gt; &lt;system systemId="common/entities.ent" &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;<br> &gt; &gt;
uri="<a class="moz-txt-link-freetext" \
href="file:///src/realms/docbook/data-repo/data/docbook-xsl-1.73">file:///src/realms/docbook/data-repo/data/docbook-xsl-1.73</a>.<br>
 &gt; 2/common/entities.ent" <br>
&gt; &gt; /&gt;<br>
&gt; &gt; but it still throws the IO Exception<br>
&gt; &gt;<br>
&gt; &gt; Thanks in advance<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Regards<br>
&gt; &gt; Navas<br>
&gt; &gt;<br>
&gt; &gt;
---------------------------------------------------------------------<br>
&gt; &gt; To unsubscribe, e-mail: <a class="moz-txt-link-abbreviated" \
href="mailto:j-users-unsubscribe@xerces.apache.org">j-users-unsubscribe@xerces.apache.org</a><br>
 &gt; &gt; For additional commands, e-mail:
<a class="moz-txt-link-abbreviated" \
href="mailto:j-users-help@xerces.apache.org">j-users-help@xerces.apache.org</a><br> \
&gt; &gt;<br> &gt; <br>
&gt;
---------------------------------------------------------------------<br>
&gt; To unsubscribe, e-mail: <a class="moz-txt-link-abbreviated" \
href="mailto:j-users-unsubscribe@xerces.apache.org">j-users-unsubscribe@xerces.apache.org</a><br>
 &gt; For additional commands, e-mail: <a class="moz-txt-link-abbreviated" \
href="mailto:j-users-help@xerces.apache.org">j-users-help@xerces.apache.org</a></tt></p>
  <pre wrap="">
<hr size="4" width="90%">
No virus found in this incoming message.
Checked by AVG. 
Version: 7.5.524 / Virus Database: 270.4.0/1506 - Release Date: 6/17/2008 4:30 PM
  </pre>
</blockquote>
<br>
</body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic