I was trying to validate a xml file using xsd wherein a node value should be non-empty. Means there should be atleast one non-whitespace character into that. After lots of googling, I finally wrote up a small pattern to validate that. Here is the fragment.

Define a new type derived from string type and apply the pattern constraint.

<!-- Non-empty string -->

<xs:simpleType name="NonEmptyString">

<xs:restriction base="xs:string">

<xs:minLength value="1" />

<xs:pattern value=".*[^\s].*" />

</xs:restriction>

</xs:simpleType>

Now use the new type "NonEmptyString" for all the nodes you want to enforce non-empty constraint.

<xs:element name="Name" type="NonEmptyString" />