XML Schema for Node with attribute and text

S

Simon Vaillancourt

I've tried to find how to write a schema for this type of node
everywhere.

<Param name="FirstParam">ABCD</Param>

How do i arrange a complex type that contains an attribute and a text.
This :
<xs:complexType name="Param">
<xs:attribute name="name" />
</xs:complexType>
Result as :
<invalid char="13" code="cvc-complex-type.1.2" line="3086"
resource="file:///C:/WINNT/Profiles/svaillan/Desktop/XML
Schema/test.xml">element Param must be empty but is not</invalid>

This :
<xs:complexType name="Param">
<xs:all>
<xs:element name="text" type="xs:string" />
</xs:all>
<xs:attribute name="name" />
</xs:complexType>
Result as :
<invalid char="13" code="cvc-complex-type.1.2.3" line="3086"
resource="file:///C:/WINNT/Profiles/svaillan/Desktop/XML
Schema/test.xml">text not allowed: |ABCD|</invalid>


I just dont know where to add the unnamed <xs:element ... > tag.

Anyone can help me figure this out?

Thx
 
P

Patrick TJ McPhee

% I've tried to find how to write a schema for this type of node
% everywhere.
%
% <Param name="FirstParam">ABCD</Param>
%
% How do i arrange a complex type that contains an attribute and a text.


Use xs:simpleContent.

<xs:complexType name="Param">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top