Re: [xml] DTD vs. Schema



On Tue, Nov 18, 2003 at 04:07:32PM +0100, Enno Rehling wrote:
We have very simple document types. For an application I write, I would 
like to get information from the docuemnt type about the docuemnt's 
structure:
- What kind of elements can an element hold?
- What kind of attributed can the element have?
- What data type is allowed for them?

In the general case, this is pretty hairy, but in our case it should be 
simple:
- Element ordering is never important.
- Elements are always either 0 or more, 1 or more, or exactly one.
- There's nothing that requires me to do switches (no rules like <A> 
contains *either * <B> *or* <C>)

I've been able to get the structure from the DTD. Sample code below 
(comments appreciated). However, I'm stumped when I have to do this with 

  Hum, there are more specific routines from the valid module
    http://xmlsoft.org/html/libxml-valid.html#xmlValidGetPotentialChildren

either RelaxNG or Schema definitions. And if I understand correctly, I'm 
pretty limited in what I can do with DTDs in terms of Data Type constraints 
(can't say "non-negative integer, 4 digits") so I would much rather be 
using schemas...

Anyone that can point me in the right direction here?

  Unfortunately there equivalent APIs for XML schemas or Relax-NG.
In the Relax-NG case you need a context to provide possible children
because the content model of an element can depend of the context.

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]