You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Fred Toth <ft...@synernet.com> on 2003/09/15 18:51:41 UTC
No support for SAX DTDHandler() - guidance please?
Hi,
Last week I discovered that the XSLT function "unparsed-entity-uri()" does not
work in cocoon transforms.
After digging around a bit, I discovered that cocoon's SAX handlers to not
contain
any support for the SAX DTDHandler interface which contains the methods that
are necessary to make this work. In particular "unparsedEntityDecl()" (most
important) and "notationDecl()".
I am considering adding this, and I am hoping for some guidance from developers
that are familiar with this part of the code. It seems that since both
Xerces and
Xalan support this, it should be relatively straight forward to have
cocoon's plumbing
"get out of the way". But I could be very wrong.
Any discussion of the topic would be helpful. I have found my way as far as the
XMLConsumer interface. I have also verified that Xerces does not require
validation
to be turned for these events to be generated.
For those of you unfamiliar with unparsed entities, they are commonly used
in local
DTD subsets to provide indirection for things like graphic file names. For
example:
Given XML source like this:
<?xml version="1.0"?>
<!DOCTYPE ..." [
<!ENTITY figf1 SYSTEM "test.jpg" NDATA JPEG>
]
...
<fig entname="figf1">
...
and XSLT like this:
...
<xsl:template match="fig">
<img><xsl:attribute name="src"><xsl:value-of
select="unparsed-entity-uri(@entname)" /></xsl:attribute></img>
</xsl:template>
I should see this in output (this works with the Xalan command line):
<img src="file:test.jpg" />
But instead, I get an empty string:
<img src="" />
As you can see, without this function there is no way to recover the original
graphic file name.
Thanks,
Fred
Re: No support for SAX DTDHandler() - guidance please?
Posted by David Crossley <cr...@indexgeo.com.au>.
Hi Fred, i want to encourage you to persist with this.
It is very important that an XML framework can deal with
all aspects of XML.
However i don't seem to have much guidance to offer you,
so please keep asking questions. Hopefully these few tips
will help ...
The package lib/endorsed/xml-apis.jar has some classes that
you will need. This comes from Apache XML Commons [1].
The Catalog Entity Resolver [2] is related to your issue.
It comes from the Apache XML Commons project [1]. It is hooked
to the parser via Cocoon class org.apache.cocoon.components.resolver
which utilises org.apache.excalibur.xml.DefaultEntityResolver [3]
now from Avalon Excalibur [4] (excalibur-xmlutil-20030520.jar).
[1] http://xml.apache.org/commons/
[2] http://cocoon.apache.org/2.1/userdocs/concepts/catalog.html
[3]
http://cvs.apache.org/viewcvs.cgi/avalon-excalibur/xmlutil/src/java/org/apache/excalibur/xml/
[4] http://avalon.apache.org/excalibur/
--David
Fred Toth wrote:
> Hi,
>
> Last week I discovered that the XSLT function "unparsed-entity-uri()"
> does not work in cocoon transforms.
>
> After digging around a bit, I discovered that cocoon's SAX handlers
> to not contain any support for the SAX DTDHandler interface which
> contains the methods that are necessary to make this work.
> In particular "unparsedEntityDecl()" (most important) and
> "notationDecl()".
>
> I am considering adding this, and I am hoping for some guidance from
> developers that are familiar with this part of the code. It seems that
> since both Xerces and Xalan support this, it should be relatively
> straight forward to have cocoon's plumbing "get out of the way".
> But I could be very wrong.
>
> Any discussion of the topic would be helpful. I have found my way
> as far as the XMLConsumer interface. I have also verified that
> Xerces does not require validation to be turned for these events
> to be generated.
>
> For those of you unfamiliar with unparsed entities, they are commonly
> used in local DTD subsets to provide indirection for things like
> graphic file names. For example:
>
> Given XML source like this:
>
> <?xml version="1.0"?>
> <!DOCTYPE ..." [
> <!ENTITY figf1 SYSTEM "test.jpg" NDATA JPEG>
> ]
> ...
> <fig entname="figf1">
> ...
>
> and XSLT like this:
>
> ...
> <xsl:template match="fig">
> <img><xsl:attribute name="src"><xsl:value-of
> select="unparsed-entity-uri(@entname)" /></xsl:attribute></img>
> </xsl:template>
>
> I should see this in output (this works with the Xalan command line):
>
> <img src="file:test.jpg" />
>
> But instead, I get an empty string:
>
> <img src="" />
>
> As you can see, without this function there is no way to recover the
> original graphic file name.
>
> Thanks,
>
> Fred