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 Aleksandar Milanovic <am...@galdosinc.com> on 2002/10/21 03:26:04 UTC
superfluous whitespaces
Hi All,
Given the fact that whitespaces can pop up in unwanted places and often
unintentionally caused by using XML editors or other XML tools wouldn't it
make sense to treat superfluous whitespaces as validation warnings rather
than errors?
The s/w application in question is a web service that validates XML requests
against an XML schema. The document elements of all requests are
empty-content elements. Requests from some clients contain superfluous
whitespaces in the element content of the respective document elements.
Xerces 2.2.0 declares these requests as invalid (I would say justifiably),
and they're thus rejected. The problem is that this approach may be too
strict. Not all client applications are "sophisticated" enough to send
perfectly valid XML requests. In many cases, it is just the matter of
whitespaces. Is it possible to somehow instruct Xerces validator to ignore
superfluous whitespaces without changing the XML schema?
thx
Alex
RE: superfluous whitespaces
Posted by Aleksandar Milanovic <am...@galdosinc.com>.
Sorry, I realized that this "problem" occurs only for empty-content
elements, i.e. those that have no text content and no child elements. I was
initially worried that this problem might occur for any indented XML, but
that is not the case.
Alex
> -----Original Message-----
> From: Aleksandar Milanovic [mailto:amilanovic@galdosinc.com]
> Sent: Monday, October 21, 2002 10:32 AM
> To: xerces-j-user@xml.apache.org
> Subject: RE: superfluous whitespaces
>
>
> Thx for your reply. My comments are inline:
>
> > -----Original Message-----
> > From: Elliotte Rusty Harold [mailto:elharo@metalab.unc.edu]
> > Sent: Monday, October 21, 2002 4:16 AM
> > To: xerces-j-user@xml.apache.org
> > Subject: Re: superfluous whitespaces
> >
> >
> > At 6:26 PM -0700 10/20/02, Aleksandar Milanovic wrote:
> > Hi All,
> >
> > Given the fact that whitespaces can pop up in unwanted places and
> > often unintentionally caused by using XML editors or other XML tools
> > wouldn't it make sense to treat superfluous whitespaces as validation
> > warnings rather than errors?
> >
> >
> > Validation errors do not necessarily stop processing. You can
> > continue working with an invalid document ifd you choose.
>
> True, but there are some errors one doesn't want to ignore. There is no
> reliable way to differentiate validation errors (string matching is not a
> good way).
>
> >
> >
> > The s/w application in question is a web service that validates XML
> > requests against an XML schema. The document elements of all
> > requests are empty-content elements. Requests from some clients
> > contain superfluous whitespaces in the element content of the
> > respective document elements. Xerces 2.2.0 declares these requests as
> > invalid (I would say justifiably), and they're thus rejected. The
> > problem is that this approach may be too strict. Not all client
> > applications are "sophisticated" enough to send perfectly valid XML
> > requests. In many cases, it is just the matter of whitespaces. Is it
> > possible to somehow instruct Xerces validator to ignore superfluous
> > whitespaces without changing the XML schema?
> >
> >
> > NO, that would be nonconformant with the W#C XML Schema Language. On
> > the other hand, you can write your schema in such a way that extra
> > white space is not reported as an error.
>
> The schemas are not under my control. They are parts of specifications
> issued by a consortium of companies. I could tweak them to get
> this to work
> in my application, but the problem will not be solved in general. Also, it
> would be odd to define every complex type of mixed content only to prevent
> these validation errors.
>
>
> > --
> >
> > +-----------------------+------------------------+-------------------+
> > | Elliotte Rusty Harold | elharo@metalab.unc.edu | Writer/Programmer |
> > +-----------------------+------------------------+-------------------+
> > | XML in a Nutshell, 2nd Edition (O'Reilly, 2002) |
> > | http://www.cafeconleche.org/books/xian2/ |
> > | http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/ |
> > +----------------------------------+---------------------------------+
> > | Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
> > | Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
> > +----------------------------------+---------------------------------+
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
RE: superfluous whitespaces
Posted by Aleksandar Milanovic <am...@galdosinc.com>.
Thx for your reply. My comments are inline:
> -----Original Message-----
> From: Elliotte Rusty Harold [mailto:elharo@metalab.unc.edu]
> Sent: Monday, October 21, 2002 4:16 AM
> To: xerces-j-user@xml.apache.org
> Subject: Re: superfluous whitespaces
>
>
> At 6:26 PM -0700 10/20/02, Aleksandar Milanovic wrote:
> Hi All,
>
> Given the fact that whitespaces can pop up in unwanted places and
> often unintentionally caused by using XML editors or other XML tools
> wouldn't it make sense to treat superfluous whitespaces as validation
> warnings rather than errors?
>
>
> Validation errors do not necessarily stop processing. You can
> continue working with an invalid document ifd you choose.
True, but there are some errors one doesn't want to ignore. There is no
reliable way to differentiate validation errors (string matching is not a
good way).
>
>
> The s/w application in question is a web service that validates XML
> requests against an XML schema. The document elements of all
> requests are empty-content elements. Requests from some clients
> contain superfluous whitespaces in the element content of the
> respective document elements. Xerces 2.2.0 declares these requests as
> invalid (I would say justifiably), and they're thus rejected. The
> problem is that this approach may be too strict. Not all client
> applications are "sophisticated" enough to send perfectly valid XML
> requests. In many cases, it is just the matter of whitespaces. Is it
> possible to somehow instruct Xerces validator to ignore superfluous
> whitespaces without changing the XML schema?
>
>
> NO, that would be nonconformant with the W#C XML Schema Language. On
> the other hand, you can write your schema in such a way that extra
> white space is not reported as an error.
The schemas are not under my control. They are parts of specifications
issued by a consortium of companies. I could tweak them to get this to work
in my application, but the problem will not be solved in general. Also, it
would be odd to define every complex type of mixed content only to prevent
these validation errors.
> --
>
> +-----------------------+------------------------+-------------------+
> | Elliotte Rusty Harold | elharo@metalab.unc.edu | Writer/Programmer |
> +-----------------------+------------------------+-------------------+
> | XML in a Nutshell, 2nd Edition (O'Reilly, 2002) |
> | http://www.cafeconleche.org/books/xian2/ |
> | http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/ |
> +----------------------------------+---------------------------------+
> | Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
> | Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
> +----------------------------------+---------------------------------+
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: superfluous whitespaces
Posted by Elliotte Rusty Harold <el...@metalab.unc.edu>.
At 6:26 PM -0700 10/20/02, Aleksandar Milanovic wrote:
Hi All,
Given the fact that whitespaces can pop up in unwanted places and
often unintentionally caused by using XML editors or other XML tools
wouldn't it make sense to treat superfluous whitespaces as validation
warnings rather than errors?
Validation errors do not necessarily stop processing. You can
continue working with an invalid document ifd you choose.
The s/w application in question is a web service that validates XML
requests against an XML schema. The document elements of all
requests are empty-content elements. Requests from some clients
contain superfluous whitespaces in the element content of the
respective document elements. Xerces 2.2.0 declares these requests as
invalid (I would say justifiably), and they're thus rejected. The
problem is that this approach may be too strict. Not all client
applications are "sophisticated" enough to send perfectly valid XML
requests. In many cases, it is just the matter of whitespaces. Is it
possible to somehow instruct Xerces validator to ignore superfluous
whitespaces without changing the XML schema?
NO, that would be nonconformant with the W#C XML Schema Language. On
the other hand, you can write your schema in such a way that extra
white space is not reported as an error.
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo@metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| XML in a Nutshell, 2nd Edition (O'Reilly, 2002) |
| http://www.cafeconleche.org/books/xian2/ |
| http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org