OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Subtyping in XML

[ Lists Home | Date Index | Thread Index ]

I'm sure this is an old chestnut, but as long as we're on the topic of
expanded value spaces for restricted types:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
   <xs:element name="root">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="foo" type="testString" maxOccurs="4"/>
         </xs:sequence>
      </xs:complexType>
   </xs:element>

   <xs:simpleType name="testString">
      <xs:restriction base="xs:string">
         <xs:pattern value="This is a test"/>
      </xs:restriction>
   </xs:simpleType>

   <xs:simpleType name="testStringR">
      <xs:restriction base="testString">
         <xs:whiteSpace value="collapse"/>
      </xs:restriction>
   </xs:simpleType>
</xs:schema>

The type testStringR is actually less restrictive than it's base in terms of
the values it accepts:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
  xsi:noNamespaceSchemaLocation="ws.xsd">

	<foo>This is a test</foo>
	<foo xsi:type="testStringR">This is a test</foo>

	<foo xsi:type="testStringR">This       is a test</foo>  <!--
restricted type accepts -->
	<foo>This       is a test</foo>
<!-- base type fails -->
</root>







 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS