Re: [xml] defaults in DTD defns?

Date view Thread view Subject view Author view

From: Charlie Bozeman (cbozeman@HiWAAY.net)
Date: Tue Jan 23 2001 - 22:51:00 EST


"Paul D. Smith" wrote:
>
> Does libxml support default values in the DTD in any way (in addition to
> recognizing them)?
>
> Should it?
>
> I have a DTD with default values and I kind of assumed that, if I didn't
> supply a value in the XML file, libxml will fill in the default value
> into the parse tree.
>
> But, that doesn't seem to be happening.
>
> Is there some approved/supported way of handling DEFAULT DTD values?
>
> E.g.,
>
> <!ATTLIST Spec
> Name CDATA #REQUIRED
> Type (Normal|Abnormal) "Normal" >
>
> then:
>
> <Spec Name="Sponge">
>
> When I look at the parse tree, there doesn't seem to be any help for
> getting the default value for the Type attribute.
>
There is nothing special about the default value, libxml will set the
attribute to the defined default value. You can access it like so:
..
  if (!xmlStrcmp(node->name, BAD_CAST "Spec")) {
      xmlChar *type;

     type = xmlGetProp(node, BAD_CAST "Type");

     if (!xmlStrcmp(BAD_CAST "Normal", type))
         printf("found default!\n");
  }
..
> --
> -------------------------------------------------------------------------------
> Paul D. Smith <psmith@baynetworks.com> HASMAT--HA Software Methods & Tools
> "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
> -------------------------------------------------------------------------------
> These are my opinions---Nortel Networks takes no responsibility for them.
> ----
> Message from the list xml@rpmfind.net
> Archived at : http://xmlsoft.org/messages/
> to unsubscribe: echo "unsubscribe xml" | mail majordomo@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 : Wed Jan 24 2001 - 00:43:45 EST