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 "RAHMAN,ABDUR (HP-Sunnyvale,ex1)" <ab...@hp.com> on 2001/02/22 01:32:09 UTC

DTD DOM-like model

Hi all,

I need some solution regarding DTD parsing. Here's the problem we're facing
and I'd appreciate if someone can give me feedback on this:

We are building an XML editor. After feeding the DTD, we want a DTD memory
model as close to DOM as possible which will present the DTD as a tree
format so it can treverse. This will generate a DOM like object which is not
text, but, rather a memory object so that we can do real-time comparison
with DMS. This concept is very similar to XML DOM model.

In a similar fashion, we may want XML memory model as opposed to a flat text
file. The main benefit of an XML memory model seems to be in chunking(divide
XML file into pieces). 

Please let me know if Apache has a solution for this or there is a third
party solution exist for this matter.

Thanks!

A. Rahman
Senior Software Engineer
Hewlett-Packard


Re: DTD DOM-like model

Posted by Andy Clark <an...@apache.org>.
"RAHMAN,ABDUR (HP-Sunnyvale,ex1)" wrote:
> Please let me know if Apache has a solution for this or there 
> is a third party solution exist for this matter.

No we don't have a solution for this at the time. However, I 
think that this could be supported in the future by building
a DOM document from the XNI DTD callbacks. Here's a completely
made-up example:

  <!ENTITY % string 'CDATA'>
  <!ELEMENT foo (bar)*>
  <!ELEMENT bar EMPTY>
  <!ATTLIST bar baz %string; #REQUIRED>

  <dtd xmlns='http://xml.apache.org/Xerces2/DTD'>
   <entityDecl name='%string' value='CDATA'/>
   <elementDecl name='foo'>
    <children occurs='*'>
     <elementRef name='bar'/>
    </children>
   </elementDecl>
   <elementDecl name='bar'/>
   <attlistDecl element='bar'>
    <attributeDecl name='baz'>
     <type name='CDATA'/>
     <required/>
    </attributeDecl>
   </attlistDecl>
  </dtd>

Of course, the breakdown is completely arbitrary but I know
that a lot of people will want the separation to be very
fine-grained so that they can figure out where parameter
entities are expanded in the DTD. For example, in the
previous example, there is a parameter entity used for the
attribute declaration type. This could translate to a DOM
subtree that looks like this (pardon the bizarre syntax):

  ENTITY_REFERENCE_NODE: name='string', value=null {
    ELEMENT_NODE: name='type', value=null [
      ATTRIBUTE_NODE: name='name', value='CDATA'
    ]
  }

Your request is relevant to determing the XNI DTD callbacks. 
You should contribute to the discussion thread "[XNI] DTD 
Information Set" on the xerces-j-dev mailing list. We could
use your feedback.

-- 
Andy Clark * IBM, TRL - Japan * andyc@apache.org