[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); </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"><navas@pitsolutions.com></a> wrote on \
06/16/2008 07:12:43 AM:<br> <br>
> Mohammed Navas ck wrote:<br>
> > Dear All<br>
> ><br>
> > I am working on docbook integration into my application. In
that I <br>
> > have a file that include a entity file in a xsl file which is
included <br>
> > in another xsl file as follows<br>
> ><br>
> > <!DOCTYPE xsl:stylesheet [<br>
> > <!ENTITY % common.entities SYSTEM
"../common/entities.ent"><br>
> > %common.entities;<br>
> > ]><br>
> ><br>
> > when I tried with absolute path instead of the relative path
it works <br>
> > fine<br>
> > but I want to use the relative path itself<br>
> ><br>
> > I have replaced the code bellow<br>
> ><br>
> > <!ENTITY % common.entities SYSTEM
"../common/entities.ent"><br>
> > %common.entities;<br>
> ><br>
> > with the content of entities.ent file it also worked<br>
> ><br>
> > So I think it has some problem with the entity resolver<br>
> ><br>
> ><br>
> > Using a URIResolver the path of xsl files are getting
resolved but I <br>
> > can't resolve the entity file path .<br>
> > It throws an error like IO Exception file-name.xsl(the entity
file <br>
> > included file)<br>
> <br>
> My resolver() written is working but entityResolver() is not
getting called<br>
> Any body have why it is so<br>
> <br>
> > Is there anybody who have faced this problem?<br>
> ><br>
> > I tried to resolve this by using catalog<br>
> > for the I have added following line to catalog<br>
> > <system systemId="common/entities.ent" \
<br> > >
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>
> 2/common/entities.ent" <br>
> > /><br>
> > but it still throws the IO Exception<br>
> ><br>
> > Thanks in advance<br>
> ><br>
> ><br>
> > Regards<br>
> > Navas<br>
> ><br>
> >
---------------------------------------------------------------------<br>
> > 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>
> > 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> \
> ><br> > <br>
>
---------------------------------------------------------------------<br>
> 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>
> 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