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 _______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] http://mail.gnome.org/mailman/listinfo/xml
