Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Represent OR in XSD

Tags:

java

xml

xsd

I need to require

(firstName and lastName) OR (nameForDisplay)

in an XSD. I can get XOR if I use <xs:choice> but I can't seem to get OR.

like image 257
stevebot Avatar asked Jun 10 '11 03:06

stevebot


People also ask

How do I enable special characters in XSD?

You'll need to use # escape codes for these two characters, so &#x2122; for TM and &#x00ae; for (R).

How do you represent data types in XML Schema?

Supported XML Schema data typesMetric and key value expressions. Calculating a key performance indicator (KPI) based on other KPIs or user-defined XPath functions. Expressions to set outbound event attributes. Specification of default values.

What is the meaning of minOccurs 0 in XSD?

<xsd:element name="A" minOccurs="0"/> means A is optional and may appear at most once. <xsd:element name="A" maxOccurs="unbounded"/> means A is required and may repeat an unlimited number of times.

What does TargetNamespace mean in XSD?

The TargetNamespace is the namespace of all schema components in this schema as well as any schema included using the include element. Included schemas must either have the same target namespace as the containing schema or have no target namespace specified.


1 Answers

<choice>
  <sequence>
    <element name="firstName" />
    <element name="lastName" />
    <element name="nameForDisplay" minOccurs="0" />
  </sequence>
  <element name="nameForDisplay" />
</choice>

Ugly to have repetition, I know. You could factor out some repetition with groups.

like image 147
Peter Davis Avatar answered Oct 14 '22 11:10

Peter Davis