Re: [xml] Creating elements with "default" values supplied by a DTD

Date view Thread view Subject view Author view

From: Daniel Veillard (veillard@redhat.com)
Date: Mon Feb 26 2001 - 14:17:04 EST


On Mon, Feb 26, 2001 at 11:40:42AM +0000, Gary Pennington wrote:
>
> Hi,
>
> I have a problem which I'm not sure about how to solve most efficiently
> using libxml, so any ideas/pointers would be appreciated.
>
> I am writing a library which will create xml elements for insertion into
> a document (which is also created at runtime) which will then be
> validated. A lot of my elements carry default or fixed attributes and
> I'd like to make the API for creating these elements as simple as
> possible. Thus, when a user calls a function to create an element, I'd
> like that element to be populated with all the fixed and default
> attribute values (which may be retrieved from the DTD).
>
> The problem I have is how to extract all this information from the
> DTD and use it when new elements are created? I've tried to create a doc
> and associate a DTD with the doc (using xmlCreateIntSubset) which works
> fine from a validation point of view. However, any elements that are
> created are not populated with values from the DTD, which defeats the
> purpose of what I'm trying to achieve.
>
> Anybody got any suggestions?
>
> Gary
>
> PS I tried investigating the xmlGetDtdElementDesc function but could
> never get a definition for my elements (only a NULL pointer).

  Hum, that's strange because that's what the validation process uses
Basically this is the function you need to call, you will get the
XML Element declaration element associated to the name, then there
is an attribute declaration list that you need to follow to find
all the associated attribute as defined in the DTD, then add the ones
which are defaulted or fixed.

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard@redhat.com  | libxml Gnome XML toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Feb 26 2001 - 14:43:49 EST