Note that there are some explanatory texts on larger screens.

plurals
  1. POAny way to make default attribute values in XML get parsed in Flex based on XSD schema?
    primarykey
    data
    text
    <p>I have an xml with an xml-schema. The xml-schema defines an abstract complex type with 2 optional attributes that have default values. Then I have several complex types that extend the base one. And finally nodes of the types defined. So I load the xml and when I parse each node, the optional attributes are not present at all. I've tried fooling around with the namespaces, even:</p> <pre><code>XML.ignoreProcessingInstructions = false; </code></pre> <p>No luck. Something similar was being experienced by this guy on <a href="http://www.codingforums.com/showthread.php?t=37004" rel="nofollow noreferrer">codingforums</a>, but that was like 5 years ago. Same is happening to me with firefox 3.0.11 - the xml is shown without the default attributes. For now I'm setting the default values in code, but isn't there a way to make them available from the xml-schema?</p> <p>Sample XML-schema:</p> <pre><code>&lt;schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.myorg.org" xmlns:tns="http://www.myorg.org" elementFormDefault="qualified"&gt; &lt;element name="config" type="tns:FieldsNode"&gt;&lt;/element&gt; &lt;complexType name="FieldsNode"&gt; &lt;choice minOccurs="0" maxOccurs="unbounded"&gt; &lt;element name="ImagePicker" type="tns:ImagePickerNode" maxOccurs="unbounded" minOccurs="0"&gt; &lt;/element&gt; &lt;/choice&gt; &lt;/complexType&gt; &lt;complexType name="FieldBase"&gt; &lt;attribute use="required" name="id" type="string"&gt;&lt;/attribute&gt; &lt;attribute use="optional" default="true" name="mandatory" type="boolean"&gt; &lt;/attribute&gt; &lt;attribute default="3" name="colspan" type="int" use="optional"&gt;&lt;/attribute&gt; &lt;/complexType&gt; &lt;complexType name="ImagePickerNode"&gt; &lt;complexContent&gt; &lt;extension base="tns:FieldBase"&gt; &lt;attribute name="maxWidth" type="int" use="required"&gt;&lt;/attribute&gt; &lt;attribute name="maxHeight" type="int" use="required"&gt;&lt;/attribute&gt; &lt;/extension&gt; &lt;/complexContent&gt; &lt;/complexType&gt; </code></pre> <p></p> <p>Sample XML:</p> <pre><code>&lt;config xmlns="http://www.myorg.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.myorg.org test.xsd"&gt; &lt;ImagePicker id="somePicker" maxHeight="10" maxWidth="12"/&gt; &lt;ImagePicker id="someOtherPicker" maxHeight="100" maxWidth="212" colspan="1" mandatory="false"/&gt; &lt;/config&gt; </code></pre> <p>Edit: added sample xml and schema.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload