The W3C XML Schema Language uses the whiteSpace facet to specify whether white space in an attribute or element with a simple type should be preserved, replaced , or collapsed .
However, once again this only offers a hint to the client application. The parser will still report all white space to the client application in the same way it would without the schema. Indeed, the whiteSpace facet doesn't even change the set of valid content for an element. For example, suppose the shape element is declared in a schema like the one below. <xsd:element name="shape"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:whiteSpace value="collapse"/> </xsd:restriction> </xsd:element> The following three elements are all still valid. <shape> triangle rectangle square </shape> <shape>triangle rectangle square</shape> <shape> triangle rectangle square </shape> Bottom line: White space is significant in XML documents except in the prolog, epilog, and tags. Parsers report all white space in element content and attribute values to the client application. Depending on the DTD, the xml:space attribute, and the value of the whiteSpace facet in the schema, parsers may indicate that white space is or is not significant. However, it will all be reported . It is up to each individual application to determine the rules by which white space is treated. |