XML/XML Schema/whiteSpace

Материал из Web эксперт
Версия от 11:25, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

xs:whiteSpace defines the way to handle whitespaces

   <source lang="xml">

i.e., #x20 (space), #x9 (tab), #xA (linefeed), and #xD (carriage return) <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

 targetNamespace="http://www.wbex.ru" 
 xmlns="http://www.wbex.ru"
 elementFormDefault="qualified">
 <xs:simpleType name="CapitalizedNameWS">
   <xs:restriction base="xs:string">
     <xs:whiteSpace value="collapse" />
     <xs:pattern value="([A-Z]([a-z]*) ?)+" />
   </xs:restriction>
 </xs:simpleType>

</xs:schema>

</source>
   
  


xs:whiteSpace defines whitespace and can expand the set of accepted instance documents during a "restriction,"

   <source lang="xml">

<?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"

 targetNamespace="http://www.wbex.ru" 
 xmlns="http://www.wbex.ru"
 elementFormDefault="qualified">
 
 <xsd:simpleType name="greetings">
   <xsd:restriction base="xsd:string">
     <xsd:whiteSpace value="replace" />
     <xsd:enumeration value="hi" />
     <xsd:enumeration value="hello" />
     <xsd:enumeration value="how do you do?" />
   </xsd:restriction>
 </xsd:simpleType>
 <xsd:simpleType name="restricted-greetings">
   <xsd:restriction base="greetings">
     <xsd:whiteSpace value="collapse" />
   </xsd:restriction>
 </xsd:simpleType>

</xsd:schema>

</source>