You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Simon Rowland <sr...@gmail.com> on 2007/02/03 23:45:21 UTC
XInclude exceptions - how to mirror Xerces J functionality into Xerces
C++?
Hi there,
I'm writing an XInclude module for the Xerces C++ parser. Currently I am
writing a DOMDocument -> DOMDocument transformer. Next I will write a
SAX filter to do it live in the parse.
I have a quick question about the Xerces-J implementation and it's
Exceptions. Basically I want to propagate XInclude error messages out of
my module into the client application.
My current thinking is to create a sublcass of XMLException, as many
other Xerces C++ internal errors do (e.g. PlatformUtils etc). This is
also the closest thing I can spot to a similar mechanism to the Xerces J
XInclude code, which uses a XMLParseException which is a sublcass of the
generic XNIException.
My understanding of the spec is that it doesn't specify what we use, as
long as we stop doing the XInclude when we encounter a fatal error.
So any advice from those that have been down the XInclude investgiation
route already? Anything gratefully received!
Many thanks in advance, Simon Rowland.
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
Re: Typo in RangeToken.java - Please check
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Dave,
I managed to create a test case which hits that code path. I've verified
it works now. That was a good catch. Thanks for the fix.
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
"Dave Brosius" <db...@apache.org> wrote on 02/04/2007 11:07:36 PM:
> No, i just saw the src2begin <= src2begin
>
>
> ----- Original Message -----
> From: "Michael Glavassevich" <mr...@ca.ibm.com>
> To: <j-...@xerces.apache.org>
> Sent: Sunday, February 04, 2007 6:55 PM
> Subject: Re: Typo in RangeToken.java - Please check
>
>
> > Dave,
> >
> > "Dave Brosius" <db...@apache.org> wrote on 02/04/2007 04:32:49 AM:
> >
> >> In org.apache.xerces.impl.xpath.regex.RangeToken.java
> >>
> >> in method protected void intersectRanges(Token token)
> >>
> >>
> >> around line 352
> >>
> >> if (src2begin <= src2begin && src1end <= src2end) {
> >> // src1: o--------o
> >> // src2:
o------------o
> >> // res: o--------o
> >> // Reuse src2
> >>
> >>
> >> from the pretty picture, i'd say it should be
> >>
> >> if (src2begin <= src1begin && src1end <= src2end) {
> >
> > I'm not too familiar with this code but based on the comments this
looks
> > right. Do you happen to have a test case to verify it?
> >
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> >> For additional commands, e-mail: j-dev-help@xerces.apache.org
> >
> > Thanks.
> >
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: mrglavas@ca.ibm.com
> > E-mail: mrglavas@apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-dev-help@xerces.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
Re: Typo in RangeToken.java - Please check
Posted by Dave Brosius <db...@apache.org>.
No, i just saw the src2begin <= src2begin
----- Original Message -----
From: "Michael Glavassevich" <mr...@ca.ibm.com>
To: <j-...@xerces.apache.org>
Sent: Sunday, February 04, 2007 6:55 PM
Subject: Re: Typo in RangeToken.java - Please check
> Dave,
>
> "Dave Brosius" <db...@apache.org> wrote on 02/04/2007 04:32:49 AM:
>
>> In org.apache.xerces.impl.xpath.regex.RangeToken.java
>>
>> in method protected void intersectRanges(Token token)
>>
>>
>> around line 352
>>
>> if (src2begin <= src2begin && src1end <= src2end) {
>> // src1: o--------o
>> // src2: o------------o
>> // res: o--------o
>> // Reuse src2
>>
>>
>> from the pretty picture, i'd say it should be
>>
>> if (src2begin <= src1begin && src1end <= src2end) {
>
> I'm not too familiar with this code but based on the comments this looks
> right. Do you happen to have a test case to verify it?
>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
>> For additional commands, e-mail: j-dev-help@xerces.apache.org
>
> Thanks.
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
Re: Typo in RangeToken.java - Please check
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Dave,
"Dave Brosius" <db...@apache.org> wrote on 02/04/2007 04:32:49 AM:
> In org.apache.xerces.impl.xpath.regex.RangeToken.java
>
> in method protected void intersectRanges(Token token)
>
>
> around line 352
>
> if (src2begin <= src2begin && src1end <= src2end) {
> // src1: o--------o
> // src2: o------------o
> // res: o--------o
> // Reuse src2
>
>
> from the pretty picture, i'd say it should be
>
> if (src2begin <= src1begin && src1end <= src2end) {
I'm not too familiar with this code but based on the comments this looks
right. Do you happen to have a test case to verify it?
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org
Thanks.
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
Typo in RangeToken.java - Please check
Posted by Dave Brosius <db...@apache.org>.
In org.apache.xerces.impl.xpath.regex.RangeToken.java
in method protected void intersectRanges(Token token)
around line 352
if (src2begin <= src2begin && src1end <= src2end) {
// src1: o--------o
// src2: o------------o
// res: o--------o
// Reuse src2
from the pretty picture, i'd say it should be
if (src2begin <= src1begin && src1end <= src2end) {
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
Re: XInclude exceptions - how to mirror Xerces J functionality into Xerces
C++?
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Simon,
Simon Rowland <sr...@gmail.com> wrote on 02/04/2007 11:47:50 AM:
> Thanks Michael, I really appreciate the reply. In the xerces c case, the
> standard DOMParser to which I am adding xi as a feature can either
> report errors through the clients errorHandler, which takes a
> DOMException, or throw XMLException, which the client is expected to
catch.
>
> I'm currently favouring adding an XMLException, since extending
> DOMException seems to go against its pretty tight spec:
>
http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-17189187
> Several other modules inside the DOMParser e.g. platform utils etc
> extend the XMLException too, so it seems inkeeping.
I don't know enough about Xerces-C++ to say whether that's the right
approach. If you were doing this in Java for JAXP (DocumentBuilder) or DOM
Level 3 (LSParser) it would be pretty clear what to do.
DocumentBuilder [1]: Call fatalError() on the registered ErrorHandler and
then throw a SAXParseException.
LSParser [2]: Call handleError() on the registered DOMErrorHandler and
then throw an LSException.
> I've asked on c-dev too.
>
> Thanks again for the help, Simon.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org
[1]
http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/parsers/DocumentBuilder.html
[2]
http://xerces.apache.org/xerces2-j/javadocs/api/org/w3c/dom/ls/LSParser.html
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
Re: XInclude exceptions - how to mirror Xerces J functionality into
Xerces C++?
Posted by Simon Rowland <sr...@gmail.com>.
Michael Glavassevich wrote:
> Hi Simon,
>
> Simon Rowland <sr...@gmail.com> wrote on 02/03/2007 05:45:21 PM:
>
> The XInclude spec doesn't say but the various XML APIs (SAX, DOM, JAXP,
> StAX, etc...) do specify how errors are reported. Xerces-J's internal
> error reporting mechanism was designed so that it could support them. This
> includes reporting the error to a registered error handler and throwing an
> exception with location information (e.g. SAXParseException and
> XMLStreamException) up to the application if the error was fatal or if the
> error handler threw an exception. If you're planning to add XInclude
> support to Xerces-C++ as a new SAX/DOM parser feature [1] and/or as a new
> parameter [2] for DOM normalization [3] you should use the error reporting
> mechanisms which already exist for these APIs.
>
>
> [1] http://xerces.apache.org/xerces2-j/features.html#xinclude
> [2]
> http://xerces.apache.org/xerces2-j/javadocs/api/org/w3c/dom/DOMConfiguration.html
> [3]
> http://xerces.apache.org/xerces2-j/javadocs/api/org/w3c/dom/Document.html#normalizeDocument()
>
>
Thanks Michael, I really appreciate the reply. In the xerces c case, the
standard DOMParser to which I am adding xi as a feature can either
report errors through the clients errorHandler, which takes a
DOMException, or throw XMLException, which the client is expected to catch.
I'm currently favouring adding an XMLException, since extending
DOMException seems to go against its pretty tight spec:
http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-17189187
Several other modules inside the DOMParser e.g. platform utils etc
extend the XMLException too, so it seems inkeeping.
I've asked on c-dev too.
Thanks again for the help, Simon.
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
Re: XInclude exceptions - how to mirror Xerces J functionality into Xerces
C++?
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Simon,
Simon Rowland <sr...@gmail.com> wrote on 02/03/2007 05:45:21 PM:
> Hi there,
>
> I'm writing an XInclude module for the Xerces C++ parser. Currently I am
> writing a DOMDocument -> DOMDocument transformer. Next I will write a
> SAX filter to do it live in the parse.
>
> I have a quick question about the Xerces-J implementation and it's
> Exceptions. Basically I want to propagate XInclude error messages out of
> my module into the client application.
>
> My current thinking is to create a sublcass of XMLException, as many
> other Xerces C++ internal errors do (e.g. PlatformUtils etc). This is
> also the closest thing I can spot to a similar mechanism to the Xerces J
> XInclude code, which uses a XMLParseException which is a sublcass of the
> generic XNIException.
>
> My understanding of the spec is that it doesn't specify what we use, as
> long as we stop doing the XInclude when we encounter a fatal error.
The XInclude spec doesn't say but the various XML APIs (SAX, DOM, JAXP,
StAX, etc...) do specify how errors are reported. Xerces-J's internal
error reporting mechanism was designed so that it could support them. This
includes reporting the error to a registered error handler and throwing an
exception with location information (e.g. SAXParseException and
XMLStreamException) up to the application if the error was fatal or if the
error handler threw an exception. If you're planning to add XInclude
support to Xerces-C++ as a new SAX/DOM parser feature [1] and/or as a new
parameter [2] for DOM normalization [3] you should use the error reporting
mechanisms which already exist for these APIs.
> So any advice from those that have been down the XInclude investgiation
> route already? Anything gratefully received!
>
> Many thanks in advance, Simon Rowland.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org
[1] http://xerces.apache.org/xerces2-j/features.html#xinclude
[2]
http://xerces.apache.org/xerces2-j/javadocs/api/org/w3c/dom/DOMConfiguration.html
[3]
http://xerces.apache.org/xerces2-j/javadocs/api/org/w3c/dom/Document.html#normalizeDocument()
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org