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:"Ar= ial","sans-serif"">I realize now what I’d like isnR= 17;t possible with XML Schema 1.0. We’ll deal with the content = length during processing. 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","sans-serif";color:#AF1932"><o:p> </o:p></sp= an></i></b></p> <p class=3D"MsoNormal"><b><span style=3D"font-size:10.0pt;font-family:"= ;Tahoma","sans-serif"">From:</span></b><span style=3D"font-s= ize:10.0pt;font-family:"Tahoma","sans-serif""> 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> </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 "length" in the presence of mixed cont= ent?<o:p></o:p></p> <div> <p class=3D"MsoNormal"><o:p> </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> </o:p></p> </div> <div> <p class=3D"MsoNormal"><productName>My Favorite Widget<entityRef r= ef=3D"trademark"/></productName><o:p></o:p></p> </div> <div> <p class=3D"MsoNormal"><o:p> </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> </o:p></p> <div> <p class=3D"MsoNormal">On Tue, Aug 20, 2013 at 9:26 AM, Hintz, David <<a= href=3D"mailto:[email protected]" target=3D"_blank">david.hintz@siem= ens.com</a>> 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:"Arial",&quo= t;sans-serif"">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:"Arial",&quo= t;sans-serif""> </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:"Arial",&quo= t;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 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:"Arial",&quo= t;sans-serif""> </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:"Arial",&quo= t;sans-serif""> <xs:element name=3D"productName">= ;</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:"Arial",&quo= t;sans-serif""> <xs:simpleType></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:"Arial",&quo= t;sans-serif""> <xs:restriction base= =3D"xs:string"></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:"Arial",&quo= t;sans-serif""> <xs:minLe= ngth value=3D"1"/></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:"Arial",&quo= t;sans-serif""> <xs:maxLe= ngth value=3D"255"/></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:"Arial",&quo= t;sans-serif""> </xs: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:"Arial",&quo= t;sans-serif""> </xs:simpleType></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:"Arial",&quo= t;sans-serif""> </xs:element></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:"Arial",&quo= t;sans-serif""> </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:"Arial",&quo= t;sans-serif"">Obviously, I want “productName” to be a cha= racter string of 1 to 255 characters. Now, I’d like to add an e= lement to “productName” – for example “entityRef” (= 0 to unbounded occurrences). So, I’d need to change “prod= uctName” to <complexType mixed=3D”true”>, but I can= ’t figure out how to add the element and maintain the restriction for= the overall length of “productName”. 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:"Arial",&quo= t;sans-serif""> </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:"Arial",&quo= t;sans-serif""> <xs:element name=3D"productName">= ;</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:"Arial",&quo= t;sans-serif""> <xs:complexType mixed=3D"tru= e"></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:"Arial",&quo= t;sans-serif""> <xs:choice minOccurs= =3D"0" maxOccurs=3D"unbounded"></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:"Arial",&quo= t;sans-serif""> <xs:eleme= nt ref=3D"entityRef"/></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:"Arial",&quo= t;sans-serif""> </xs:choice></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:"Arial",&quo= t;sans-serif""> </xs:complexType></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:"Arial",&quo= t;sans-serif""> </xs:element></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:"Arial",&quo= t;sans-serif""> </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:"Arial",&quo= t;sans-serif"">Anyone have a simple solution for maintaining the restr= iction of 1-255 characters in length? 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:"Arial",&quo= t;sans-serif""> </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:"Arial",&quo= t;sans-serif"">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:"Arial",&quo= t;sans-serif""> </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:"Arial",&quo= t;sans-serif"">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:"Arial",&quo= t;sans-serif"">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> </o:p></p> </div> <p class=3D"MsoNormal">-- <br> <strong><span style=3D"font-size:9.0pt;font-family:"Helvetica",&q= uot;sans-serif"">Lyle Kopnicky</span></strong><span style=3D"font-size= :9.0pt;font-family:"Helvetica","sans-serif"">, <em= ><span style=3D"font-family:"Helvetica","sans-serif"">S= oftware Engineer</span></em>, </span><a href=3D"http://bit.ly/cKKudR" = target=3D"_blank"><span style=3D"font-size:9.0pt;font-family:"Helvetic= a","sans-serif"">Janrain, Inc.</span></a><span style=3D"font-size:9.0pt;font-family:"Helvetica&= quot;,"sans-serif""><br> E: </span><a href=3D"mailto:[email protected]" target=3D"_blank"><span = style=3D"font-size:9.0pt;font-family:"Helvetica","sans-serif= "">[email protected]</span></a><span style=3D"font-size:9.0pt;font-fami= ly:"Helvetica","sans-serif""> | W: 503-488-6754<br= > Follow Janrain: </span><a href=3D"http://bit.ly/9CGHdf" target=3D"_bla= nk"><span style=3D"font-size:9.0pt;font-family:"Helvetica","= sans-serif"">Facebook</span></a><span style=3D"font-size:9.0pt;font-fa= mily:"Helvetica","sans-serif""> | </span><a h= ref=3D"http://bit.ly/9umxlK" target=3D"_blank"><span style=3D"font-size:9.0= pt;font-family:"Helvetica","sans-serif"">Twitter</span>= </a><span style=3D"font-size:9.0pt;font-family:"Helvetica","= sans-serif""> | </span><a href=3D"http://bit.ly/N0OiBT" targ= et=3D"_blank"><span style=3D"font-size:9.0pt;font-family:"Helvetica&qu= ot;,"sans-serif"">YouTube</span></a><span style=3D"font-size:9.0p= t;font-family:"Helvetica","sans-serif""> | </= span><a href=3D"http://bit.ly/a7WZMC" target=3D"_blank"><span style=3D"font= -size:9.0pt;font-family:"Helvetica","sans-serif"">Linke= dIn</span></a><span style=3D"font-size:9.0pt;font-family:"Helvetica&qu= ot;,"sans-serif""> | </span><a href=3D"http://bit.ly/OI= 2uOR" target=3D"_blank"><span style=3D"font-size:9.0pt;font-family:"He= lvetica","sans-serif"">Blog</span></a><span style=3D"font-si= ze:9.0pt;font-family:"Helvetica","sans-serif""><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_--