Hi Yves,

Currently, if the document has no DTD, there's no mechanism for using a DTD
to validate it.  I doubt this would be too hard to build in, and if someone
were to implement it (under some kind of appropriate feature since it would
be non-conformant to the XML spec), I suspect the odds of the work making
it into CVS would be pretty good.

Note that schemas don't have this limitation; you don't need any
schemaLocation in your document in order for schema validation to occur.

Cheers,
Neil
Neil Graham
XML Parser Development
IBM Toronto Lab
Phone:  905-413-3519, T/L 969-3519
E-mail:  [EMAIL PROTECTED]




                                                                                       
                                                 
                      "Yves Monier"                                                    
                                                 
                      <[EMAIL PROTECTED]        To:       <[EMAIL PROTECTED]>          
                                       
                      -group.com>               cc:                                    
                                                 
                                                Subject:  Validating an XML document 
against an external DTD                            
                      09/01/2003 12:09                                                 
                                                 
                      PM                                                               
                                                 
                      Please respond to                                                
                                                 
                      xerces-c-dev                                                     
                                                 
                                                                                       
                                                 
                                                                                       
                                                 



Hello,

I use xerces-c 2.1.0.

The XML files I need to validate:
- contain NO reference to the DTD (e.g. no DOCTYPE).
- don't contain the xml header (<?xml version ... ?>), though this is not
the issue here

XML example:

<DICT>
<SE clevel="2">
<HW>maison</HW>
<S1>
<O1>
<PS>noun</PS>
</O1>
<S2>
<S3>
<!--noun-->
<TR>house</TR>
</S3>
</S2>
</S1>
</SE>
</DICT>

The DTD against which I need to validate will probably be stored in a
MemBufInputSource object: I don't need (want) to have an external file to
store it.

DTD:
<!DOCTYPE DICT [
<!ELEMENT DICT (SE+)>
<!ELEMENT SE (HW,S1+)>
  <!ATTLIST SE clevel (2) \"2\">
<!ELEMENT HW (#PCDATA)>
<!ELEMENT S1 (O1,S2)>
<!ELEMENT O1 (PS)>
<!ELEMENT PS (#PCDATA)>
<!ELEMENT S2 (S3+)>
<!ELEMENT S3 (LC?,CPDRE?,TR+)>
<!ELEMENT CPDRE (#PCDATA)>
<!ELEMENT LC (#PCDATA)>
<!ELEMENT TR (#PCDATA)>
]>


I have seen many messages more or less related to the subject of this
message. It seems that a/the solution resides in:
- using the grammar caching mechanism
and/or
- using a specific EntityResolver

I tried different solutions but up to now none of them worked:

Using DTD caching mechanism:
- create an in-memory XML buffer containing inline DTD + a small piece of
data which conforms to the DTD
- create a validating parser
- parse the in-memory input source then set parser's
fgXercesUseCachedGrammarInParse feature to true
- parse actual XML files using the same parser --> still validation errors

Using my own EntityResolver:
- the resolveEntity is not called, so that I can't feed the parser with my
DTD definition. I guess this is because the XML doesn't contain DOCTYPE
definition... By the way, having no DOCTYPE is maybe the reason why the
grammar caching doesn't work (if cached grammars are more or less
associated
to their DOCTYPE, what occurs if there is no DOCTYPE?)

Did somebody faced the same problem? Is there a way to have my
EntityResolver's resolveEntity method called despite the fact that the XML
doesn't contain DOCTYPE definition?

Thanks in advance for any suggestion,

Yves


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to