tags:

views:

31

answers:

2

I have XML that looks like this:

<Parameter Name="parameter name" Value="parameter value" />

which I defined in XSD like this:

<xs:complexType name="Parameter">
   <xs:attribute name="Name" type="xs:string" use="required" />
   <xs:attribute name="Value" type="xs:string" use="required" />
</xs:complexType>

but what I really want is the XML to look like this:

<Parameter Name="parameter name">parameter value<Parameter/>

I can't figure out how I do this in XSD. How would the XSD look like?

+4  A: 

You want a complex element that can contain text only - in other words, text and attributes.

This is done using the "simpleContent" specifier, like so:

<xs:element name="Parameter">
  <xs:complexType>
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="Name" type="xs:string" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:element>
womp
Awesome. Thanks so much!
Hermann
A: 

Starting with XML Schema the primer should give you some starting point.

zedoo