3

The xml looks like:

<Asset>
    <NAME>XX905886XX58</NAME>
</Asset>
<Asset>
    <NAME>XX905886XX58             </NAME>
</Asset>`

I have validation in my xsd file for duplicated <NAME> tag. But, in described below XML, i would like to validate <NAME> after trimming. The question: is it possible to trim value before validation? Ho to do it in xsd?

My xsd validation code:

<xs:unique name="UniqueAsset">
  <xs:selector xpath="Asset"/>
  <xs:field xpath="NAME"/>
</xs:unique>`

UPDATE

It works if add to XSD <xs:whiteSpace value="collapse"/>:

  <xs:element name="NAME">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:whiteSpace value="collapse"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
May12
  • 2,420
  • 12
  • 63
  • 99

1 Answers1

3

If the type of the element NAME is derived from xs:token (or anything else with the whitespace facet "collapse"), then the uniqueness test will apply to the value after whitespace-trimming.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164