You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Mohammed Navas ck <na...@pitsolutions.com> on 2008/06/16 11:54:29 UTC

Entity resolving problem in Docbook

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)

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


Re: Entity resolving problem in Docbook

Posted by Mohammed Navas ck <na...@pitsolutions.com>.
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 <na...@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
>   


Re: Entity resolving problem in Docbook

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Mohammed,

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.

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)

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Mohammed Navas ck <na...@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

Re: Entity resolving problem in Docbook

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Mohammed,

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.

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)

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Mohammed Navas ck <na...@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

Re: Entity resolving problem in Docbook

Posted by Mohammed Navas ck <na...@pitsolutions.com>.
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