Adding restriction to a complexType
"Hintz, David" <[email protected]> Tue, 20 Aug 2013 16:26:11 +0000
| Newsgroups | gmane.text.xml.schema.devel |
|---|---|
| Message-ID | <5EFB55C97F483B43ABC8CE62890AA476D69DBFFC@USSLMMBX003.net.plm.eds.com> |
--_000_5EFB55C97F483B43ABC8CE62890AA476D69DBFFCUSSLMMBX003netp_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hello,
Using XML Schema 1.0, I'm having a problem trying to add a restriction to a=
complexType. I've got this element definition:
<xs:element name=3D"productName">
<xs:simpleType>
<xs:restriction base=3D"xs:string">
<xs:minLength value=3D"1"/>
<xs:maxLength value=3D"255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Obviously, I want "productName" to be a character string of 1 to 255 charac=
ters. Now, I'd like to add an element to "productName" - for example "enti=
tyRef" (0 to unbounded occurrences). So, I'd need to change "productName" =
to <complexType mixed=3D"true">, but I can't figure out how to add the elem=
ent and maintain the restriction for the overall length of "productName". =
This gets me close, but I lose the restriction:
<xs:element name=3D"productName">
<xs:complexType mixed=3D"true">
<xs:choice minOccurs=3D"0" maxOccurs=3D"unbounded">
<xs:element ref=3D"entityRef"/>
</xs:choice>
</xs:complexType>
</xs:element>
Anyone have a simple solution for maintaining the restriction of 1-255 char=
acters in length? Or, is this even possible?
Thanks,
Dave Hintz
Siemens
--_000_5EFB55C97F483B43ABC8CE62890AA476D69DBFFCUSSLMMBX003netp_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Arial","sans-serif";
color:#AF1932;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"blue" vlink=3D"purple">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif"">Hello,<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif"">Using XML Schema 1.0, I’m having a =
problem trying to add a restriction to a complexType. I’ve got =
this element definition:<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""> <xs:element name=3D"produc=
tName"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""> <xs:simpleType><=
o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""> <xs:res=
triction base=3D"xs:string"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif"">  =
; <xs:minLength value=3D"1"/><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif"">  =
; <xs:maxLength value=3D"255"/><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""> </xs:re=
striction><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""> </xs:simpleType>=
<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""> </xs:element><o:p></o:p></sp=
an></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif"">Obviously, I want “productName̶=
1; to be a character string of 1 to 255 characters. Now, I’d li=
ke to add an element to “productName” – for example ̶=
0;entityRef” (0 to unbounded
occurrences). So, I’d need to change “productName”=
to <complexType mixed=3D”true”>, but I can’t figur=
e out how to add the element and maintain the restriction for the overall l=
ength of “productName”. This gets me close, but I lose th=
e restriction:<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""> <xs:element name=3D"produc=
tName"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""> <xs:complexType mix=
ed=3D"true"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""> <xs:cho=
ice minOccurs=3D"0" maxOccurs=3D"unbounded"><o:p></o=
:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif"">  =
; <xs:element ref=3D"entityRef"/><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""> </xs:ch=
oice><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""> </xs:complexType>=
;<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""> </xs:element><o:p></o:p></sp=
an></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif"">Anyone have a simple solution for maintai=
ning the restriction of 1-255 characters in length? Or, is this even =
possible?<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif"">Thanks,<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif""><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif"">Dave Hintz<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:"Ar=
ial","sans-serif"">Siemens<o:p></o:p></span></p>
</div>
</body>
</html>
--_000_5EFB55C97F483B43ABC8CE62890AA476D69DBFFCUSSLMMBX003netp_--