Jump to content

xml to xsd


King_Ming

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 comment
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 comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...