You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Vladimir Loubenski <vl...@opentext.com> on 2010/07/28 17:13:17 UTC

Validate the data contained in a DOM tree

Hi,
My understanding that single way to validate data (Validation against
XML schema) in a DOM tree is to create the DOM document, write it back
as XML and re-parse it with validation turned on. Are there plans to
support validation direct from the DOM tree?

Regards,
Vladimir. 


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: Validate the data contained in a DOM tree

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
"B.W.H. van Beest" <bw...@xs4all.nl> wrote on 07/30/2010 05:19:17 PM:

> Hi,
>
> I would like to support this request, but broaden it so that its
> usefulness is bigger.
> The functionality that I think would be much more useful is to have
> not only the possibility to validate in memory a given DOM-tree (for
> which there indeed exists a work-around -however, see below), but
> the functionality that I'm really looking for is to ask a given DOM-
> node which attributes/child elements are allowed (and how many)
> according to the schema.  This would allow you to interactively edit
> a DOM-tree, with suggestions which edits are possible.
> From the outside this looks a related topic: if validation fails, I
> would like to know what the correct options are that would lead to
> validation.
> But here I might be completely wrong. I would like to hear Boris'
opinion.
> Anyway, an api that supports this type f functionalty would be
> extremely useful.

There's a W3C standard API (DOM Level 3 Validation) [1] for that but I
don't think it ever got widely implemented.

> Now on the in-memory validation:  my experience is that this works
> ok if the validation succeeds. However, if validation fails and you
> want to print details of what and where the error occurs, I always
> get core dumps. So instead I serialise a DOM-tree first to a
> temporary file on disk, the do the validation with possible error
> reporting on this temporary file.
> I would love to see how it is supposed to be done. Earlier requests
> along this line in this newsgroup have not lead to any answer, but
> the problem remains..
>
>
>
> Kind Regards,
> Bertwim

[1] http://www.w3.org/TR/DOM-Level-3-Val/validation.html

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

Re: Validate the data contained in a DOM tree

Posted by "B.W.H. van Beest" <bw...@xs4all.nl>.
Hi,

I would like to support this request, but broaden it so that its
usefulness is bigger.
The functionality that I think would be much more useful is to have not
only the possibility to validate in memory a given DOM-tree (for which
there indeed exists a work-around -however, see below), but the
functionality that I'm really looking for is to ask a given DOM-node
which attributes/child elements are allowed (and how many) according to
the schema.  This would allow you to interactively edit a DOM-tree, with
suggestions which edits are possible.
>From the outside this looks a related topic: if validation fails, I
would like to know what the correct options are that would lead to
validation.
But here I might be completely wrong. I would like to hear Boris' opinion.
Anyway, an api that supports this type f functionalty would be extremely
useful.

Now on the in-memory validation:  my experience is that this works ok if
the validation succeeds. However, if validation fails and you want to
print details of what and where the error occurs, I always get core
dumps. So instead I serialise a DOM-tree first to a temporary file on
disk, the do the validation with possible error reporting on this
temporary file.
I would love to see how it is supposed to be done. Earlier requests
along this line in this newsgroup have not lead to any answer, but the
problem remains..



Kind Regards,
Bertwim


Vladimir Loubenski wrote:
> Hi Boris,
> Michael described Xerces-J functionality to validate a DOM in-memory
> that we need for.
> Could you consider to implement it in a near future?
>  
> Thank you,
> ------------------------------------------------------------------------
> *Vladimir Loubenski* 
> Senior Software Developer
> R&D, Genio 
> <http://www.opentext.com/2/email-signature-logo-global-event>
> *Open Text* 	 
> <http://www.opentext.com/2/email-signature-event-global-event>
> 38 Leek Crescent,
> Richmond Hill L4B-4N8 ONT
> Canada 
>
> Phone:      +1 905 762 6001 ext. 6985
>  
> 	  	
> Email: 	_vloubens_@opentext.com <ma...@opentext.com>
> Web site: 	http://www.opentext.com/
>
>
> This email is protected by domestic and international copyright laws
> and treaties and is the property of Open Text Corporation, it may
> contain confidential and/or trade secret information of the Open Text
> Corporation and/or its subsidiaries (OTC), and may be subject to legal
> privilege in favor of OTC. This email may only be lawfully received,
> accessed, displayed on a computer screen, printed, copied, and/or used
> by the specific addressee(s) named above ("Authorized Recipient") for
> the purpose for which it was sent by OTC. All other rights and
> licenses to this email are fully reserved to OTC. If you are not an
> Authorized Recipient, you are required to immediately delete this
> email in its entirety without printing, copying, using, and/or
> re-transmitting this email, either in whole or in part. The
> transmission of this email by OTC is not to be construed as a waiver
> by OTC and/or the individual sending this email on behalf of OTC of
> any of their respective rights or privileges at law or otherwise,
> howsoever arising.
>
>   
>
> ------------------------------------------------------------------------
> *From:* Michael Glavassevich [mailto:mrglavas@ca.ibm.com]
> *Sent:* July 30, 2010 11:21 AM
> *To:* c-dev@xerces.apache.org
> *Subject:* Re: Validate the data contained in a DOM tree
>
> Boris,
>
> Xerces-J has had the ability to validate a DOM in-memory for years. It
> behaves as if you serialized and then reparsed the document with
> schema validation enabled except that it's much more efficient (firing
> SAX like events to the schema validator from a walk of the DOM tree).
> I think that's what Vladimir is asking for, not fail-fast setters /
> continuous validation which seems to be the topic in the post you
> referenced.
>
> Thanks.
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> Boris Kolpackov <bo...@codesynthesis.com> wrote on 07/30/2010 11:07:24 AM:
>
> > Hi Vladimir,
> >
> > Vladimir Loubenski <vl...@opentext.com> writes:
> >
> > > My understanding that single way to validate data (Validation against
> > > XML schema) in a DOM tree is to create the DOM document, write it back
> > > as XML and re-parse it with validation turned on. Are there plans to
> > > support validation direct from the DOM tree?
> >
> > No, there are no plans to support this at the moment. It is also
> > questionable how useful this feature will be since it is not clear
> > what one can do when a validation error has been detected. There
> > are some errors that will be hard/impossible to fix programmatically
> > (say, pattern validation error). For a more detailed discussion of
> > this topic, see the following post:
> >
> >
> http://www.codesynthesis.com/pipermail/xsd-users/2008-January/001443.html
> >
> > Boris
> >
> > --
> > Boris Kolpackov, Code Synthesis      
>  http://codesynthesis.com/~boris/blog
> <http://codesynthesis.com/%7Eboris/blog>
> > Open-source XML data binding for C++  
> http://codesynthesis.com/products/xsd
> > XML data binding for embedded systems
>  http://codesynthesis.com/products/xsde
> > Command line interface to C++ compiler
> http://codesynthesis.com/projects/cli
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: c-dev-help@xerces.apache.org
>

RE: Validate the data contained in a DOM tree

Posted by Vladimir Loubenski <vl...@opentext.com>.
Hi Boris, 
Michael described Xerces-J functionality to validate a DOM in-memory
that we need for.
Could you consider to implement it in a near future?
 
Thank you,
________________________________

Vladimir Loubenski 	
Senior Software Developer
R&D, Genio 	
  <http://www.opentext.com/2/email-signature-logo-global-event>  
Open Text 	 	  
<http://www.opentext.com/2/email-signature-event-global-event>  	
38 Leek Crescent, 
Richmond Hill L4B-4N8 ONT
Canada 	
	
Phone:      +1 905 762 6001 ext. 6985	
 
 	 	
Email:	 vloubens@opentext.com <ma...@opentext.com> 	
Web site:	 http://www.opentext.com/	


This email is protected by domestic and international copyright laws and
treaties and is the property of Open Text Corporation, it may contain
confidential and/or trade secret information of the Open Text
Corporation and/or its subsidiaries (OTC), and may be subject to legal
privilege in favor of OTC. This email may only be lawfully received,
accessed, displayed on a computer screen, printed, copied, and/or used
by the specific addressee(s) named above ("Authorized Recipient") for
the purpose for which it was sent by OTC. All other rights and licenses
to this email are fully reserved to OTC. If you are not an Authorized
Recipient, you are required to immediately delete this email in its
entirety without printing, copying, using, and/or re-transmitting this
email, either in whole or in part. The transmission of this email by OTC
is not to be construed as a waiver by OTC and/or the individual sending
this email on behalf of OTC of any of their respective rights or
privileges at law or otherwise, howsoever arising.

  

________________________________

From: Michael Glavassevich [mailto:mrglavas@ca.ibm.com] 
Sent: July 30, 2010 11:21 AM
To: c-dev@xerces.apache.org
Subject: Re: Validate the data contained in a DOM tree



Boris,

Xerces-J has had the ability to validate a DOM in-memory for years. It
behaves as if you serialized and then reparsed the document with schema
validation enabled except that it's much more efficient (firing SAX like
events to the schema validator from a walk of the DOM tree). I think
that's what Vladimir is asking for, not fail-fast setters / continuous
validation which seems to be the topic in the post you referenced.

Thanks.

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

Boris Kolpackov <bo...@codesynthesis.com> wrote on 07/30/2010 11:07:24
AM:

> Hi Vladimir,
> 
> Vladimir Loubenski <vl...@opentext.com> writes:
> 
> > My understanding that single way to validate data (Validation
against
> > XML schema) in a DOM tree is to create the DOM document, write it
back
> > as XML and re-parse it with validation turned on. Are there plans to
> > support validation direct from the DOM tree?
> 
> No, there are no plans to support this at the moment. It is also 
> questionable how useful this feature will be since it is not clear
> what one can do when a validation error has been detected. There
> are some errors that will be hard/impossible to fix programmatically
> (say, pattern validation error). For a more detailed discussion of
> this topic, see the following post:
> 
> 
http://www.codesynthesis.com/pipermail/xsd-users/2008-January/001443.htm
l
> 
> Boris
> 
> -- 
> Boris Kolpackov, Code Synthesis        
http://codesynthesis.com/~boris/blog
> Open-source XML data binding for C++   
http://codesynthesis.com/products/xsd
> XML data binding for embedded systems  
http://codesynthesis.com/products/xsde
> Command line interface to C++ compiler 
http://codesynthesis.com/projects/cli
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: c-dev-help@xerces.apache.org



Re: Validate the data contained in a DOM tree

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

Xerces-J has had the ability to validate a DOM in-memory for years. It
behaves as if you serialized and then reparsed the document with schema
validation enabled except that it's much more efficient (firing SAX like
events to the schema validator from a walk of the DOM tree). I think that's
what Vladimir is asking for, not fail-fast setters / continuous validation
which seems to be the topic in the post you referenced.

Thanks.

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

Boris Kolpackov <bo...@codesynthesis.com> wrote on 07/30/2010 11:07:24 AM:

> Hi Vladimir,
>
> Vladimir Loubenski <vl...@opentext.com> writes:
>
> > My understanding that single way to validate data (Validation against
> > XML schema) in a DOM tree is to create the DOM document, write it back
> > as XML and re-parse it with validation turned on. Are there plans to
> > support validation direct from the DOM tree?
>
> No, there are no plans to support this at the moment. It is also
> questionable how useful this feature will be since it is not clear
> what one can do when a validation error has been detected. There
> are some errors that will be hard/impossible to fix programmatically
> (say, pattern validation error). For a more detailed discussion of
> this topic, see the following post:
>
> http://www.codesynthesis.com/pipermail/xsd-users/2008-January/001443.html
>
> Boris
>
> --
> Boris Kolpackov, Code Synthesis
http://codesynthesis.com/~boris/blog
> Open-source XML data binding for C++
http://codesynthesis.com/products/xsd
> XML data binding for embedded systems
http://codesynthesis.com/products/xsde
> Command line interface to C++ compiler
http://codesynthesis.com/projects/cli
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: c-dev-help@xerces.apache.org

Re: Validate the data contained in a DOM tree

Posted by "B.W.H. van Beest" <bw...@xs4all.nl>.
Boris (et al.)

It would be extremely useful!   The use case I have in mind is to 
have/build a tool that is working essentially as an xml editor. That is, 
the objective is to build -interactively- an instance of an xml-document 
that is compliant with a certain given schema.  A bare XML editor, like 
e.g. the  Altova XML editor does offer this functionality, but it is 
unsuited (because not open, not commercially available in the form 
needed,  and restricted to a windows platform) to take on board in our 
application.  In fact, I am not even thinking of a tool that should 
handle arbitrary schemas.

In my branch  -simulation of subsurface fluid flow-  this situation is 
typical. There exists many (industry-standard) xsd-schema;s to describe 
the various aspects that go into such a  physical simulation model (e.g. 
fluid composition, geometry, ...).   (An example from the oil industry 
can be found here: http://www.energistics.org/witsml-current-stable-version)

But what is offered to a user is not an empty xml-template that the user 
has to complete in.  Dedicated tools provide the means to enter the 
simulation data. It would be powerful if these tools could make use of 
the possibility to instantly check the validity of the data entered, or 
better, if they could offer the functionality based on the xsd schema.

In other words, a plea to reconsider the implementation!

Kind Regads,
Bertwim

On 07/30/2010 05:07 PM, Boris Kolpackov wrote:
> Hi Vladimir,
>
> Vladimir Loubenski<vl...@opentext.com>  writes:
>
>> My understanding that single way to validate data (Validation against
>> XML schema) in a DOM tree is to create the DOM document, write it back
>> as XML and re-parse it with validation turned on. Are there plans to
>> support validation direct from the DOM tree?
> No, there are no plans to support this at the moment. It is also
> questionable how useful this feature will be since it is not clear
> what one can do when a validation error has been detected. There
> are some errors that will be hard/impossible to fix programmatically
> (say, pattern validation error). For a more detailed discussion of
> this topic, see the following post:
>
> http://www.codesynthesis.com/pipermail/xsd-users/2008-January/001443.html
>
>
> Boris
>

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: Validate the data contained in a DOM tree

Posted by Boris Kolpackov <bo...@codesynthesis.com>.
Hi Vladimir,

Vladimir Loubenski <vl...@opentext.com> writes:

> My understanding that single way to validate data (Validation against
> XML schema) in a DOM tree is to create the DOM document, write it back
> as XML and re-parse it with validation turned on. Are there plans to
> support validation direct from the DOM tree?

No, there are no plans to support this at the moment. It is also 
questionable how useful this feature will be since it is not clear
what one can do when a validation error has been detected. There
are some errors that will be hard/impossible to fix programmatically
(say, pattern validation error). For a more detailed discussion of
this topic, see the following post:

http://www.codesynthesis.com/pipermail/xsd-users/2008-January/001443.html


Boris

-- 
Boris Kolpackov, Code Synthesis        http://codesynthesis.com/~boris/blog
Open-source XML data binding for C++   http://codesynthesis.com/products/xsd
XML data binding for embedded systems  http://codesynthesis.com/products/xsde
Command line interface to C++ compiler http://codesynthesis.com/projects/cli

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org