RE: Adding restriction to a complexType

"Hintz, David" <[email protected]> Tue, 20 Aug 2013 20:28:52 +0000
Newsgroups gmane.text.xml.schema.devel
Message-ID <5EFB55C97F483B43ABC8CE62890AA476D69DC15E@USSLMMBX003.net.plm.eds.com>
--_000_5EFB55C97F483B43ABC8CE62890AA476D69DC15EUSSLMMBX003netp_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

I realize now what I'd like isn't possible with XML Schema 1.0.  We'll deal=
 with the content length during processing.  But, yes, the count would incl=
ude whatever the embedded element expands to.

From: Kopnicky, Lyle [mailto:[email protected]]
Sent: Tuesday, August 20, 2013 3:18 PM
To: Hintz, David
Cc: [email protected]
Subject: Re: Adding restriction to a complexType

Could you give an example of what you're trying to allow, and what you mean=
 by "length" in the presence of mixed content?

I'm imagining you want something like this:

<productName>My Favorite Widget<entityRef ref=3D"trademark"/></productName>

In that case, should the entityRef count as 1 toward the length? Or zero? O=
r should it be expanded into some text that is then measured?

On Tue, Aug 20, 2013 at 9:26 AM, Hintz, David <[email protected]<mail=
to:[email protected]>> wrote:
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



--
Lyle Kopnicky, Software Engineer, Janrain, Inc.<http://bit.ly/cKKudR>
E: [email protected]<mailto:[email protected]> | W: 503-488-6754
Follow Janrain: Facebook<http://bit.ly/9CGHdf> | Twitter<http://bit.ly/9umx=
lK> | YouTube<http://bit.ly/N0OiBT> | LinkedIn<http://bit.ly/a7WZMC> | Blog=
<http://bit.ly/OI2uOR>
---------------------------------------------------------------------------=
----------
Acquire, understand, and engage your users. Watch our video<http://bit.ly/j=
anrain-overview> or sign up for a live demo<http://bit.ly/janraindemo> to s=
ee what it's all about.

--_000_5EFB55C97F483B43ABC8CE62890AA476D69DC15EUSSLMMBX003netp_
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:Helvetica;
	panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
	{font-family:Helvetica;
	panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman","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.EmailStyle19
	{mso-style-type:personal-reply;
	font-family:"Arial","sans-serif";
	color:#AF1932;
	font-weight:bold;
	font-style:italic;
	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:&quot;Ar=
ial&quot;,&quot;sans-serif&quot;">I realize now what I&#8217;d like isn&#82=
17;t possible with XML Schema 1.0.&nbsp; We&#8217;ll deal with the content =
length during processing.&nbsp; But, yes, the count would include whatever =
the embedded
 element expands to.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><b><i><span style=3D"font-size:10.0pt;font-family:&q=
uot;Arial&quot;,&quot;sans-serif&quot;;color:#AF1932"><o:p>&nbsp;</o:p></sp=
an></i></b></p>
<p class=3D"MsoNormal"><b><span style=3D"font-size:10.0pt;font-family:&quot=
;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style=3D"font-s=
ize:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> Kopnicky=
, Lyle [mailto:[email protected]]
<br>
<b>Sent:</b> Tuesday, August 20, 2013 3:18 PM<br>
<b>To:</b> Hintz, David<br>
<b>Cc:</b> [email protected]<br>
<b>Subject:</b> Re: Adding restriction to a complexType<o:p></o:p></span></=
p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class=3D"MsoNormal">Could you give an example of what you're trying to a=
llow, and what you mean by &quot;length&quot; in the presence of mixed cont=
ent?<o:p></o:p></p>
<div>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class=3D"MsoNormal">I'm imagining you want something like this:<o:p></o:=
p></p>
</div>
<div>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class=3D"MsoNormal">&lt;productName&gt;My Favorite Widget&lt;entityRef r=
ef=3D&quot;trademark&quot;/&gt;&lt;/productName&gt;<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class=3D"MsoNormal">In that case, should the entityRef count as 1 toward=
 the length? Or zero? Or should it be expanded into some text that is then =
measured?<o:p></o:p></p>
</div>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><o:p>&nbsp;</o:p></p>
<div>
<p class=3D"MsoNormal">On Tue, Aug 20, 2013 at 9:26 AM, Hintz, David &lt;<a=
 href=3D"mailto:[email protected]" target=3D"_blank">david.hintz@siem=
ens.com</a>&gt; wrote:<o:p></o:p></p>
<div>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">Hello,</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">Using XML Schema 1.0, I&#8217;m having a problem trying=
 to add a restriction to a complexType. &nbsp;I&#8217;ve got this element d=
efinition:</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp; &lt;xs:element name=3D&quot;productName&quot;&gt=
;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;&nbsp;&nbsp; &lt;xs:simpleType&gt;</span><o:p></o=
:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:restriction base=
=3D&quot;xs:string&quot;&gt;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:minLe=
ngth value=3D&quot;1&quot;/&gt;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:maxLe=
ngth value=3D&quot;255&quot;/&gt;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xs:restriction&gt;<=
/span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;&nbsp;&nbsp; &lt;/xs:simpleType&gt;</span><o:p></=
o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp; &lt;/xs:element&gt;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">Obviously, I want &#8220;productName&#8221; to be a cha=
racter string of 1 to 255 characters.&nbsp; Now, I&#8217;d like to add an e=
lement
 to &#8220;productName&#8221; &#8211; for example &#8220;entityRef&#8221; (=
0 to unbounded occurrences).&nbsp; So, I&#8217;d need to change &#8220;prod=
uctName&#8221; to &lt;complexType mixed=3D&#8221;true&#8221;&gt;, but I can=
&#8217;t figure out how to add the element and maintain the restriction for=
 the overall length of &#8220;productName&#8221;.&nbsp;
 This gets me close, but I lose the restriction:</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp; &lt;xs:element name=3D&quot;productName&quot;&gt=
;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;&nbsp;&nbsp; &lt;xs:complexType mixed=3D&quot;tru=
e&quot;&gt;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:choice minOccurs=
=3D&quot;0&quot; maxOccurs=3D&quot;unbounded&quot;&gt;</span><o:p></o:p></p=
>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:eleme=
nt ref=3D&quot;entityRef&quot;/&gt;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xs:choice&gt;</span=
><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;&nbsp;&nbsp; &lt;/xs:complexType&gt;</span><o:p><=
/o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp; &lt;/xs:element&gt;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">Anyone have a simple solution for maintaining the restr=
iction of 1-255 characters in length?&nbsp; Or, is this even possible?</spa=
n><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">Thanks,</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">Dave Hintz</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quo=
t;sans-serif&quot;">Siemens</span><o:p></o:p></p>
</div>
</div>
</div>
<p class=3D"MsoNormal"><br>
<br clear=3D"all">
<o:p></o:p></p>
<div>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<p class=3D"MsoNormal">-- <br>
<strong><span style=3D"font-size:9.0pt;font-family:&quot;Helvetica&quot;,&q=
uot;sans-serif&quot;">Lyle Kopnicky</span></strong><span style=3D"font-size=
:9.0pt;font-family:&quot;Helvetica&quot;,&quot;sans-serif&quot;">,&nbsp;<em=
><span style=3D"font-family:&quot;Helvetica&quot;,&quot;sans-serif&quot;">S=
oftware Engineer</span></em>,&nbsp;</span><a href=3D"http://bit.ly/cKKudR" =
target=3D"_blank"><span style=3D"font-size:9.0pt;font-family:&quot;Helvetic=
a&quot;,&quot;sans-serif&quot;">Janrain,
 Inc.</span></a><span style=3D"font-size:9.0pt;font-family:&quot;Helvetica&=
quot;,&quot;sans-serif&quot;"><br>
E:&nbsp;</span><a href=3D"mailto:[email protected]" target=3D"_blank"><span =
style=3D"font-size:9.0pt;font-family:&quot;Helvetica&quot;,&quot;sans-serif=
&quot;">[email protected]</span></a><span style=3D"font-size:9.0pt;font-fami=
ly:&quot;Helvetica&quot;,&quot;sans-serif&quot;">&nbsp;| W: 503-488-6754<br=
>
Follow Janrain:&nbsp;</span><a href=3D"http://bit.ly/9CGHdf" target=3D"_bla=
nk"><span style=3D"font-size:9.0pt;font-family:&quot;Helvetica&quot;,&quot;=
sans-serif&quot;">Facebook</span></a><span style=3D"font-size:9.0pt;font-fa=
mily:&quot;Helvetica&quot;,&quot;sans-serif&quot;">&nbsp;|&nbsp;</span><a h=
ref=3D"http://bit.ly/9umxlK" target=3D"_blank"><span style=3D"font-size:9.0=
pt;font-family:&quot;Helvetica&quot;,&quot;sans-serif&quot;">Twitter</span>=
</a><span style=3D"font-size:9.0pt;font-family:&quot;Helvetica&quot;,&quot;=
sans-serif&quot;">&nbsp;|&nbsp;</span><a href=3D"http://bit.ly/N0OiBT" targ=
et=3D"_blank"><span style=3D"font-size:9.0pt;font-family:&quot;Helvetica&qu=
ot;,&quot;sans-serif&quot;">YouTube</span></a><span style=3D"font-size:9.0p=
t;font-family:&quot;Helvetica&quot;,&quot;sans-serif&quot;">&nbsp;|&nbsp;</=
span><a href=3D"http://bit.ly/a7WZMC" target=3D"_blank"><span style=3D"font=
-size:9.0pt;font-family:&quot;Helvetica&quot;,&quot;sans-serif&quot;">Linke=
dIn</span></a><span style=3D"font-size:9.0pt;font-family:&quot;Helvetica&qu=
ot;,&quot;sans-serif&quot;">&nbsp;|&nbsp;</span><a href=3D"http://bit.ly/OI=
2uOR" target=3D"_blank"><span style=3D"font-size:9.0pt;font-family:&quot;He=
lvetica&quot;,&quot;sans-serif&quot;">Blog</span></a><span style=3D"font-si=
ze:9.0pt;font-family:&quot;Helvetica&quot;,&quot;sans-serif&quot;"><br>
---------------------------------------------------------------------------=
----------</span><o:p></o:p></p>
<div>
<p class=3D"MsoNormal"><i>Acquire, understand, and engage your users. </i><=
a href=3D"http://bit.ly/janrain-overview" target=3D"_blank"><i>Watch our vi=
deo</i></a><i> or
</i><a href=3D"http://bit.ly/janraindemo" target=3D"_blank"><i>sign up for =
a live demo</i></a><i> to see what it's all about.</i><o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>

--_000_5EFB55C97F483B43ABC8CE62890AA476D69DC15EUSSLMMBX003netp_--