[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Forcing content according to attribute

From: Papalagi Pakeha <papalagi.pakeha@gmail.com>
Date: Wed, 23 Jan 2008 13:29:22 +1300
Message-ID: <343d1bca0801221629l1402f17bo8825dc9494142b31@mail.gmail.com>
To: xmlschema-dev@w3.org
Forcing content according to attribute

hello,

in our xml documents we use <Attachment> tag to specify, well,
attachments to these documents. something like:

<Doc>
<Title>xyz</Title>
....
<Attachment type="logo" format="url">http://some.url/logo.jpg</Attachment>
<Attachment type="token" format="inline">U29tZVRoaW5nCg==</Attachment>
<Attachment type="data" format="filename">local.file.bin</Attachment>
</Doc>

Is there any way in XSD to enforce:
- base64 content for format="inline",
- URL content when format="url", and
- non-URL when format="filename"
?

For now I have:

  <xs:element name="Attachment">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute name="format" use="required">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="inline"/>
                <xs:enumeration value="filename"/>
                <xs:enumeration value="url"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
          <xs:attribute name="type" use="required">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="logo"/>
                <xs:enumeration value="token"/>
                <xs:enumeration value="data"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

that works well but accepts any "xs:string" for content and not
enforcing URL/non-URL/base64.

can anyone throw some hints on how to achieve the link between format
and content please?

thanks!

papa
Received on Wednesday, 23 January 2008 04:22:21 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.