views:

29

answers:

0

Hi, Say I have a schema which defines an element as follows:

<xsd:element name="Widget" type="tns:WidgetType" />

<xsd:complexType name="WidgetType">
  <xsd:sequence>

    <xsd:element name="Name" type="xsd:normalizedString" maxOccurs="1" minOccurs="1" />
    <xsd:element name="Description" type="xsd:normalizedString" default="Unknown" maxOccurs="1" minOccurs="0" />

  </xsd:sequence>
</xsd:complexType>

I'm parsing (DOM parser) an XML file that has been validated against this schema using Xerces-C++. If the Description element is present, I know how to read it by iterating through all the child elements of the DOMElement for a given Widget and using DOMElement::getTextContent() upon finding the Description element.

But, if a particular Widget element does not have a Description child element (which is allowed by the schema), how can I fetch the default value (Unknown) from the schema?

Thanks for your responses, Ashish