Buchcik, Kasimier wrote:
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
Wow! Thank you very much, that was exactly what I was looking for!
--
David Grohmann
Senior Student Associate
Applied Research Lab : UT Austin : ESL - S206
Office: 512-835-3237
Cell: 210-861-6882
Work on Mondays, Wednesdays, and Fridays only.
|