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 "Eric J. Schwarzenbach" <Er...@wrycan.com> on 2006/11/13 21:57:36 UTC
serializing entity defs with quotes
I'm sending some old school dtd-based XML through a SAX parser mostly
just to assemble it from the dozens of xml files included in the
top-level file as entities, using the old
identity-transform-to-serialize techique:
t.transform(new SAXSource(parser, new InputSource(inStream)), new
StreamResult(outputStream));
then sending the resultant serialized bytes over the wire to another app
which will parse it again. Both parsers are Xerces-J 2.8.1. The problem
I'm running into is the XML going in has entities that look like:
<!ENTITY wan-gw
'<systemitem class="systemname">wan-gw</systemitem>' >
coming out of the serialization it looks like
<!ENTITY wan-gw "<systemitem class="systemname">wan-gw</systemitem>">
Which Xerces rejects with a
The declaration for the entity "wan-gw" must end with '>'.
My memory of entity syntax is spotty because I haven't used them in
years, but I'm assuming the problem is that with double quotes inside
the entity text, single quotes are required to quote it, but the
serializer is just assuming double quotes.
So my questions are:
1) Should this be considered a bug?
2) Is there a way to tell the serializer which kind of quotes to use
(which I assume won't really help if there are other cases with the
single quotes in the entity text).
3) Is there a better way to write that entity in the first place? Some
better way to escape the double quotes?
Thanks,
Eric
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: serializing entity defs with quotes
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
"Eric J. Schwarzenbach" <Er...@wrycan.com> wrote on
11/13/2006 05:25:11 PM:
> Right, I'm using the built-in identity-tranformation support...I'm
> pretty much just performing SAX serialization as recommended in the
> Xerces FAQ
>
> http://xerces.apache.org/xerces2-j/faq-general.html#faq-6
>
> I realized an easy answer to my third question which is to invert the
> use of quotes to
>
> <!ENTITY wan-gw
> "<systemitem class='systemname'>wan-gw</systemitem>" >
>
> Which is okay to hack my way forward for the moment, but not a solution
> for handling xml out of my control.
>
> Now I get errors like
>
> White space is required after "<!ENTITY" in the entity declaration.
>
> Because the external DTD has
>
> <!ENTITY % dbnotn SYSTEM
> "http://www.oasis-open.org/docbook/xml/configerror.txt">
>
> and the serialization turns it into:
>
> <!ENTITY %dbnotn PUBLIC "-//OASIS//ENTITIES DocBook Notations
> V4.2//EN" >
>
> I don't know if this could be one of the bugs you're alluding to, or if
> my ignorance of the fine points of entities is leading me to
misunderstand.
>
> I'm going to see if I have any better luck with the gnu XmlWriter class.
You may want to follow-up on one of the Xalan mailing lists.
I believe Xalan 2.7.1 is planned for the end of the month. If something is
awry there may still be a bit of time for the developers to get a fix into
the release.
> Eric
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: serializing entity defs with quotes
Posted by "Eric J. Schwarzenbach" <Er...@wrycan.com>.
Right, I'm using the built-in identity-tranformation support...I'm
pretty much just performing SAX serialization as recommended in the
Xerces FAQ
http://xerces.apache.org/xerces2-j/faq-general.html#faq-6
I realized an easy answer to my third question which is to invert the
use of quotes to
<!ENTITY wan-gw
"<systemitem class='systemname'>wan-gw</systemitem>" >
Which is okay to hack my way forward for the moment, but not a solution
for handling xml out of my control.
Now I get errors like
White space is required after "<!ENTITY" in the entity declaration.
Because the external DTD has
<!ENTITY % dbnotn SYSTEM
"http://www.oasis-open.org/docbook/xml/configerror.txt">
and the serialization turns it into:
<!ENTITY %dbnotn PUBLIC "-//OASIS//ENTITIES DocBook Notations
V4.2//EN" >
I don't know if this could be one of the bugs you're alluding to, or if
my ignorance of the fine points of entities is leading me to misunderstand.
I'm going to see if I have any better luck with the gnu XmlWriter class.
Eric
I
keshlam@us.ibm.com wrote:
>
> > <!ENTITY wan-gw
> > '<systemitem class="systemname">wan-gw</systemitem>' >
> >
> > coming out of the serialization it looks like
> >
> > <!ENTITY wan-gw "<systemitem class="systemname">wan-gw</systemitem>">
>
> Uhm. An XSLT transformation, even an indentity transformation, really
> shouldn't be preserving entity declarations at all; they aren't part
> of the XPath/XSLT data model, so they should be expanded on their way
> through.
>
> I suspect you're trying to use the built-in identity-tranformation
> support, rather than a real identity stylesheet. Right? If so, I'm not
> sure we ever fixed the known bugs in that code...
>
>
> ______________________________________
> "... Three things see no end: A loop with exit code done wrong,
> A semaphore untested, And the change that comes along. ..."
> -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish
> (http://www.ovff.org/pegasus/songs/threes-rev-11.html)
>
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: serializing entity defs with quotes
Posted by ke...@us.ibm.com.
> <!ENTITY wan-gw
> '<systemitem class="systemname">wan-gw</systemitem>' >
>
> coming out of the serialization it looks like
>
> <!ENTITY wan-gw "<systemitem class="systemname">wan-gw</systemitem>">
Uhm. An XSLT transformation, even an indentity transformation, really
shouldn't be preserving entity declarations at all; they aren't part of the
XPath/XSLT data model, so they should be expanded on their way through.
I suspect you're trying to use the built-in identity-tranformation support,
rather than a real identity stylesheet. Right? If so, I'm not sure we ever
fixed the known bugs in that code...
______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
-- "Threes" Rev 1.1 - Duane Elms / Leslie Fish
(http://www.ovff.org/pegasus/songs/threes-rev-11.html)