Yes, Thanks for all your help.
 
I can validate a single element now.
But I still have some questions.
 
1. Does DOM3 using GrammarPool?
 
2. when I validate document, I can specify only one schema using config.setParameter("schema-location","xxxx");
    How to specify serveral schema locations ?
 
    for example, if I want to validate a document below:
  
  <person id="four.worker">
    <name><family>Worker</family> <given>Four</given></name>
    <email>[EMAIL PROTECTED]</email>
    <link manager="Big.Boss"/>
  </person>
 
 I hava to specify the schema of person and XMLSchema.
 
 How should I do?
 
    Thank you very much.
 
Gloria
 
----- Original Message -----
Sent: Wednesday, October 01, 2003 9:41 PM
Subject: Re: How to validate an element rather than the whole xml document

----- Original Message ----- 
From: "Elena Litani" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 25, 2003 11:40 PM
Subject: Re: How to validate an element rather than the whole xml document


  
I need to validate an element aganist schema rather than the
whole document.
    

Currently, it is not possible to revalidate a singe element within the
DOM tree.
The best way of achieving what you want is using DOM Level 3
normalizeDocument that allows to revalidate a document in memory [1].
You can setup the schema on the <key> element using xsi:schemaLocation
attributes and register your own error handler that will ignore errors
for <SOAPENV:Envelope>, <SOAPBODY:Body> elements (the validator will
complain that declaration for those is not found).

If you really want to revalidate a single node.. you can create a new
document, use adoptNode to move a single element you want to revalidate
to a new document, use DOM L3 normalizeDocument on the new document to
revalidate just that single node. Then, if needed, you can use adoptNode
again to move back the element to the original document.


[1] http://xml.apache.org/xerces2-j/faq-dom.html#faq-7

Hope it helps,
  

--

Reply via email to