f



XML Schema for Node with attribute and text

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
0
11/28/2003 9:39:32 PM
comp.text.xml 8781 articles. 0 followers. Post Follow

1 Replies
599 Views

Similar Articles

[PageSpeed] 8

In article <de3c2ad2.0311281339.e74b69b@posting.google.com>,

Simon Vaillancourt <svaillancourt@mediagrif.com> wrote:
% 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>


-- 

Patrick TJ McPhee
East York  Canada
ptjm@interlog.com
0
ptjm (515)
11/30/2003 1:43:19 AM
Reply: