[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
AW: [xml] Default Values for Attributes
- From: "Buchcik, Kasimier" <k buchcik 4commerce de>
- To: "David Grohmann" <grohmann arlut utexas edu>
- Cc: xml gnome org
- Subject: AW: [xml] Default Values for Attributes
- Date: Wed, 3 May 2006 16:06:59 +0200
Hi,
> -----Ursprüngliche Nachricht-----
> Auftrag von David Grohmann
>
> Using the Tree API is there a way to get at the default value
> listed in
> the XML Schema for an optional attribute that was not included in the
> xml document?
> Reading through the libxml2 website it seems this can be done
> with the
> xmlreader API (and even then maybe only for DTDs, it is unclear)
>
> example: schema
> <xs:element name = "root_element">
> <xs:attribute name = "prop1" use="optional" default="5">
> </xs:element>
> =====================
> Xml document
> <root_element>
>
> xmlNode* node = magic_code_to_get_that_root_node();
>
> xmlChar *myAttribute = xmlGetProp(node, "prop1") <= this wont
> work, is
> it possible some other way?
This is currently only possible during a validation episode:
In xmlschemas.c there's xmlSchemaSetValidOptions() to be used
with a validation context. Setting the option
XML_SCHEMA_VAL_VC_I_CREATE will create such default attribute-nodes
in the tree, while the validation is performed.
Regards,
Kasimier
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]