2

I have the following element in my XML

<xs:MigrationUpgradeRequisitesSection ovf:required="false"> <Info>Files necessary for migration-based upgrade.</Info> <xs:Requisite xs:purpose="requirements" ovf:fileRef="xxxxx"/> </xs:MigrationUpgradeRequisitesSection>

If the ovf:required=false, I want to allow the element without doing any validation. Otherwise it should be validated.

How to write xml schema for that? My xml version is 1.0

ivoszz
  • 4,370
  • 2
  • 27
  • 27
anusuya
  • 653
  • 1
  • 9
  • 24

1 Answers1

2

As far as I know it is directly not possible, however, there may be a workaround for your case, as commented in this post:

Restricting XML Elements Based on Another Element via XSD

The first answer, does a good explanation on why it is not possible, and how to do it by applying a transformation before validating through XSD. You may transform elements with "ovf:required= false" to null elements before XSD validation.

Community
  • 1
  • 1
crigore
  • 400
  • 5
  • 23