Jump to content
hismightiness

Single Element with Attribute

Recommended Posts

I need to define a single element that has a single attribute. I am having a brain lapse or something. Can someone help me?What I need to define is this:

<myElement myAttribute="textvalue">123.45</myElement>

And this obviously doesn't work, but would define what I am trying to accomplish:

<xs:element name="myElement" type="xs:decimal" minOccurs="0" maxOccurs="1">	<xs:attribute name="myAttribute" type="xs:string" use="required" /></xs:element>

Share this post


Link to post
Share on other sites

Never mind... I most certainly did have a brain lapse. I forgot that Visual Studio has a tool that will show how to define that. Here is the answer for anyone that stumbles upon this later:

<xs:element name="myElement">	<xs:complexType>		<xs:simpleContent>			<xs:extension base="xs:decimal">				<xs:attribute name="myAttribute" type="xs:string" use="required" />			</xs:extension>		</xs:simpleContent>	</xs:complexType></xs:element>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...