Re: Adding restriction to a complexType
Michael Kay <[email protected]> Tue, 20 Aug 2013 19:47:34 +0100
| Newsgroups | gmane.text.xml.schema.devel |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_70FCDAD8-5BA4-46B4-8A8B-63DDE85CC73D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 It's not possible to restrict the text that appears within mixed content = elements - except with XSD 1.1 assertions. Michael Kay Saxonica On 20 Aug 2013, at 17:26, Hintz, David wrote: > Hello, > =20 > Using XML Schema 1.0, I=92m having a problem trying to add a = restriction to a complexType. I=92ve got this element definition: > =20 > <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> > =20 > Obviously, I want =93productName=94 to be a character string of 1 to = 255 characters. Now, I=92d like to add an element to =93productName=94 = =96 for example =93entityRef=94 (0 to unbounded occurrences). So, I=92d = need to change =93productName=94 to <complexType mixed=3D=94true=94>, = but I can=92t figure out how to add the element and maintain the = restriction for the overall length of =93productName=94. This gets me = close, but I lose the restriction: > =20 > <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> > =20 > Anyone have a simple solution for maintaining the restriction of 1-255 = characters in length? Or, is this even possible? > =20 > Thanks, > =20 > Dave Hintz > Siemens --Apple-Mail=_70FCDAD8-5BA4-46B4-8A8B-63DDE85CC73D Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252 <html><head><base href=3D"x-msg://7459/"></head><body style=3D"word-wrap: = break-word; -webkit-nbsp-mode: space; -webkit-line-break: = after-white-space; "><div>It's not possible to restrict the text that = appears within mixed content elements - except with XSD 1.1 = assertions.</div><div><br></div><div>Michael = Kay</div><div>Saxonica</div><br><div><div>On 20 Aug 2013, at 17:26, = Hintz, David wrote:</div><br = class=3D"Apple-interchange-newline"><blockquote type=3D"cite"><span = class=3D"Apple-style-span" style=3D"border-collapse: separate; = font-family: Helvetica; font-style: normal; font-variant: normal; = font-weight: normal; letter-spacing: normal; line-height: normal; = orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: = none; white-space: normal; widows: 2; word-spacing: 0px; = -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: = 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: = auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div = lang=3D"EN-US" link=3D"blue" vlink=3D"purple"><div class=3D"WordSection1" = style=3D"page: WordSection1; "><div style=3D"margin-top: 0in; = margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: = 11pt; font-family: Calibri, sans-serif; "><span style=3D"font-size: = 10pt; font-family: Arial, sans-serif; = ">Hello,<o:p></o:p></span></div><div style=3D"margin-top: 0in; = margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: = 11pt; font-family: Calibri, sans-serif; "><span style=3D"font-size: = 10pt; font-family: Arial, sans-serif; = "><o:p> </o:p></span></div><div style=3D"margin-top: 0in; = margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: = 11pt; font-family: Calibri, sans-serif; "><span style=3D"font-size: = 10pt; font-family: Arial, sans-serif; ">Using XML Schema 1.0, I=92m = having a problem trying to add a restriction to a complexType. = I=92ve got this element definition:<o:p></o:p></span></div><div = style=3D"margin-top: 0in; margin-right: 0in; margin-left: 0in; = margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, = sans-serif; "><span style=3D"font-size: 10pt; font-family: Arial, = sans-serif; "><o:p> </o:p></span></div><div style=3D"margin-top: = 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; = font-size: 11pt; font-family: Calibri, sans-serif; "><span = style=3D"font-size: 10pt; font-family: Arial, sans-serif; "> = <xs:element name=3D"productName"><o:p></o:p></span></div><div = style=3D"margin-top: 0in; margin-right: 0in; margin-left: 0in; = margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, = sans-serif; "><span style=3D"font-size: 10pt; font-family: Arial, = sans-serif; "> = <xs:simpleType><o:p></o:p></span></div><div style=3D"margin-top: = 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; = font-size: 11pt; font-family: Calibri, sans-serif; "><span = style=3D"font-size: 10pt; font-family: Arial, sans-serif; = "> <xs:restriction = base=3D"xs:string"><o:p></o:p></span></div><div style=3D"margin-top: = 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; = font-size: 11pt; font-family: Calibri, sans-serif; "><span = style=3D"font-size: 10pt; font-family: Arial, sans-serif; = "> <xs:minLength = value=3D"1"/><o:p></o:p></span></div><div style=3D"margin-top: 0in; = margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: = 11pt; font-family: Calibri, sans-serif; "><span style=3D"font-size: = 10pt; font-family: Arial, sans-serif; = "> <xs:maxLength = value=3D"255"/><o:p></o:p></span></div><div style=3D"margin-top: 0in; = margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: = 11pt; font-family: Calibri, sans-serif; "><span style=3D"font-size: = 10pt; font-family: Arial, sans-serif; "> = </xs:restriction><o:p></o:p></span></div><div style=3D"margin-top: = 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; = font-size: 11pt; font-family: Calibri, sans-serif; "><span = style=3D"font-size: 10pt; font-family: Arial, sans-serif; = "> </xs:simpleType><o:p></o:p></span></div><div = style=3D"margin-top: 0in; margin-right: 0in; margin-left: 0in; = margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, = sans-serif; "><span style=3D"font-size: 10pt; font-family: Arial, = sans-serif; "> </xs:element><o:p></o:p></span></div><div = style=3D"margin-top: 0in; margin-right: 0in; margin-left: 0in; = margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, = sans-serif; "><span style=3D"font-size: 10pt; font-family: Arial, = sans-serif; "><o:p> </o:p></span></div><div style=3D"margin-top: = 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; = font-size: 11pt; font-family: Calibri, sans-serif; "><span = style=3D"font-size: 10pt; font-family: Arial, sans-serif; ">Obviously, I = want =93productName=94 to be a character string of 1 to 255 = characters. Now, I=92d like to add an element to =93productName=94 = =96 for example =93entityRef=94 (0 to unbounded occurrences). So, = I=92d need to change =93productName=94 to <complexType = mixed=3D=94true=94>, but I can=92t figure out how to add the element = and maintain the restriction for the overall length of = =93productName=94. This gets me close, but I lose the = restriction:<o:p></o:p></span></div><div style=3D"margin-top: 0in; = margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: = 11pt; font-family: Calibri, sans-serif; "><span style=3D"font-size: = 10pt; font-family: Arial, sans-serif; = "><o:p> </o:p></span></div><div style=3D"margin-top: 0in; = margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: = 11pt; font-family: Calibri, sans-serif; "><span style=3D"font-size: = 10pt; font-family: Arial, sans-serif; "> <xs:element = name=3D"productName"><o:p></o:p></span></div><div style=3D"margin-top: = 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; = font-size: 11pt; font-family: Calibri, sans-serif; "><span = style=3D"font-size: 10pt; font-family: Arial, sans-serif; = "> <xs:complexType = mixed=3D"true"><o:p></o:p></span></div><div style=3D"margin-top: 0in; = margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: = 11pt; font-family: Calibri, sans-serif; "><span style=3D"font-size: = 10pt; font-family: Arial, sans-serif; "> = <xs:choice minOccurs=3D"0" = maxOccurs=3D"unbounded"><o:p></o:p></span></div><div = style=3D"margin-top: 0in; margin-right: 0in; margin-left: 0in; = margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, = sans-serif; "><span style=3D"font-size: 10pt; font-family: Arial, = sans-serif; "> <xs:element = ref=3D"entityRef"/><o:p></o:p></span></div><div style=3D"margin-top: = 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; = font-size: 11pt; font-family: Calibri, sans-serif; "><span = style=3D"font-size: 10pt; font-family: Arial, sans-serif; = "> = </xs:choice><o:p></o:p></span></div><div style=3D"margin-top: 0in; = margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: = 11pt; font-family: Calibri, sans-serif; "><span style=3D"font-size: = 10pt; font-family: Arial, sans-serif; "> = </xs:complexType><o:p></o:p></span></div><div style=3D"margin-top: = 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; = font-size: 11pt; font-family: Calibri, sans-serif; "><span = style=3D"font-size: 10pt; font-family: Arial, sans-serif; "> = </xs:element><o:p></o:p></span></div><div style=3D"margin-top: = 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; = font-size: 11pt; font-family: Calibri, sans-serif; "><span = style=3D"font-size: 10pt; font-family: Arial, sans-serif; = "><o:p> </o:p></span></div><div style=3D"margin-top: 0in; = margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: = 11pt; font-family: Calibri, sans-serif; "><span style=3D"font-size: = 10pt; font-family: Arial, sans-serif; ">Anyone have a simple solution = for maintaining the restriction of 1-255 characters in length? Or, = is this even possible?<o:p></o:p></span></div><div style=3D"margin-top: = 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; = font-size: 11pt; font-family: Calibri, sans-serif; "><span = style=3D"font-size: 10pt; font-family: Arial, sans-serif; = "><o:p> </o:p></span></div><div style=3D"margin-top: 0in; = margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: = 11pt; font-family: Calibri, sans-serif; "><span style=3D"font-size: = 10pt; font-family: Arial, sans-serif; = ">Thanks,<o:p></o:p></span></div><div style=3D"margin-top: 0in; = margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: = 11pt; font-family: Calibri, sans-serif; "><span style=3D"font-size: = 10pt; font-family: Arial, sans-serif; = "><o:p> </o:p></span></div><div style=3D"margin-top: 0in; = margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: = 11pt; font-family: Calibri, sans-serif; "><span style=3D"font-size: = 10pt; font-family: Arial, sans-serif; ">Dave = Hintz<o:p></o:p></span></div><div style=3D"margin-top: 0in; = margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: = 11pt; font-family: Calibri, sans-serif; "><span style=3D"font-size: = 10pt; font-family: Arial, sans-serif; = ">Siemens<o:p></o:p></span></div></div></div></span></blockquote></div><br= ></body></html>= --Apple-Mail=_70FCDAD8-5BA4-46B4-8A8B-63DDE85CC73D--