Jump to content

Recommended Posts

Hi,

 

I'm trying to create an xsd with restriction for the following but I can't seem to find an example of how to do it properly. Basically its a string element that has an attribute. What I'm trying to do is have restriction on both the Name and the Number.

 

So for example, for Name, I want to only allow [a-t]*, and for number I want it to be 0 -100.

 

Thanks in advance,

 

~Ming

 

XML

<Name Number="10">abcdeft</Name>
Link to post
Share on other sites

Hi, I'm trying to create an xsd with restriction for the following but I can't seem to find an example of how to do it properly. Basically its a string element that has an attribute. What I'm trying to do is have restriction on both the Name and the Number. So for example, for Name, I want to only allow [a-t]*, and for number I want it to be 0 -100. Thanks in advance, ~Ming XML

<Name Number="10">abcdeft</Name>
This seem to be for facetRestrictionAnd PatternAttributePattern These are the schema's elements you will need to make this work...<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XML/Schema" version="1.0"><xs:element name="name"><xs:complexType><xs:restriction base="xs:string"><xs:pattern value="[A-T]*[a-t]*" /><xs:attribute name="Number"><xs:simpleType><xs:restriction base="xs:integer"><xs:pattern value="[0-9]+" /><xs:maxInclusion value="100" /><xs:minInclusion value="0" /></xs:restriction></xs:simpleType></xs:attribute></xs:restriction></xs:complexType></xs:element></xs:schema>I'm on my phone doing this, so they may be errors. Please give me a like for my efforts. Edited by L8V2L
Link to post
Share on other sites
  • 1 month later...

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...