in reply to Re: XML parser to fetch default values of the optional attributes from the xsd file
in thread XML parser to fetch default values of the optional attributes from the xsd file

then you can return the default value from the XSD

One would first need to identify the relevant schema definition for a given element or attribute. How do you propose to do that?

  • Comment on Re^2: XML parser to fetch default values of the optional attributes from the xsd file

Replies are listed 'Best First'.
Re^3: XML parser to fetch default values of the optional attributes from the xsd file
by roboticus (Chancellor) on Jan 11, 2011 at 18:59 UTC

    ikegami:

    I assumed that if he (a) could detect that the defaults are missing, and (b) can track down the correct values, that he already knows how to identify the correct values.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

      He's asking how to do (b), if not both (a) and (b), so it's not a very good assumption.

      Update: That was not very well put. The following explains what I meant.

      I would expect that he wants get_attributes($ele) to return all present attributes and all absent attributes for which the schema defines a default.

      To achieve that automatically, one must automatically determine (a) which attributes are missing and (b) what are the default for those attributes.

      Another scenario is that he simply wants get_attribute($ele, 'foo') to return the specified value for the attribute, or the default otherwise if it's not specified.

      To achieve that automatically, one must automatically determine (b) what is the default for that attribute.

      For both scenarios, you simply assumed the OP could already solve all but the trivial portions of his problem.