RE: Adding restriction to a complexType

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 include whatever the embedded element expands to.

From: Kopnicky, Lyle [mailto:lyle@janrain.com]
Sent: Tuesday, August 20, 2013 3:18 PM
To: Hintz, David
Cc: xmlschema-dev@w3.org
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="trademark"/></productName>

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?

On Tue, Aug 20, 2013 at 9:26 AM, Hintz, David <david.hintz@siemens.com<mailto:david.hintz@siemens.com>> 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="productName">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:minLength value="1"/>
        <xs:maxLength value="255"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>

Obviously, I want "productName" to be a character string of 1 to 255 characters.  Now, I'd like to add an element to "productName" - for example "entityRef" (0 to unbounded occurrences).  So, I'd need to change "productName" to <complexType mixed="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:

  <xs:element name="productName">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="entityRef"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>

Anyone have a simple solution for maintaining the restriction of 1-255 characters in length?  Or, is this even possible?

Thanks,

Dave Hintz
Siemens



--
Lyle Kopnicky, Software Engineer, Janrain, Inc.<http://bit.ly/cKKudR>
E: lyle@janrain.com<mailto:lyle@janrain.com> | W: 503-488-6754
Follow Janrain: Facebook<http://bit.ly/9CGHdf> | Twitter<http://bit.ly/9umxlK> | 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/janrain-overview> or sign up for a live demo<http://bit.ly/janraindemo> to see what it's all about.

Received on Tuesday, 20 August 2013 20:29:23 UTC