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

RE: schema content model question


schema fuzz
In XML Schema, you can add attributes to an element with simple content
using an anonymous complex type as a child of the element declaration.
Something like will work:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="foo">
 <xs:complexType>
  <xs:simpleContent>
   <xs:restriction base="xs:string">
    <xs:enumeration value="fizz"/>
    <xs:enumeration value="fuzz"/>
   </xs:restriction>
  </xs:simpleContent>
   <xs:attribute name="bar" type="Bar"/>
 </xs:complexType>
</xs:element>

<xs:simpleType name="Bar">
 <xs:restriction base="xs:string">
  <xs:enumeration value="glorp"/>
  <xs:enumeration value="glop"/>
 </xs:restriction>
</xs:simpleType>

</xs:schema>

The syntax for RELAX NG (12 lines) is somewhat simpler than the XML Schema
syntax (18 lines). For example:

<element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
 <attribute name="bar">
  <choice>
   <value>glorp</value>
   <value>glop</value>
  </choice>
 </attribute>
 <choice>
  <value>fizz</value>
  <value>fuzz</value>
 </choice>
</element>

Here is a valid instance for both schemas, tested with MSV:

<?xml version="1.0"?>

<foo bar="glorp">fuzz</foo>


Mike

-----Original Message-----
From: Morgan V. Cundiff [mailto:mcundiff@l...]
Sent: Wednesday, March 06, 2002 8:18 AM
To: xml-dev@l...
Subject:  schema content model question



I have been attempting to create an XML Schema content model for an
element like the following:

- the element should contain text only, no subeleemnts (simpleContent?)
- the permissable values of the element should be restricted to a list of
enumerated string values
- the element should also have attributes with values which are also
restricted to list of enumerated string values.

Is this possible? I have made several attempts which I will send if it is
useful for discussion but I thought perhaps someone can just provide the
answer.

thanks,
Morgan Cundiff
Library of Congress


-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://lists.xml.org/ob/adm.pl>



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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-2013 All Rights Reserved.