Hi Frans,
Your DTD model:
(title | Action | ActionList | Separator | WeakSeparator |
TearOffHandle | Merge | MergeLocal | DefineGroup | Menu )*
in XML Schema will be:
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="title"/>
<xsd:element ref="Action"/>
<xsd:element ref="ActionList"/>
<xsd:element ref="Separator"/>
<xsd:element ref="WeakSeparator"/>
<xsd:element ref="TearOffHandle"/>
<xsd:element ref="Merge"/>
<xsd:element ref="MergeLocal"/>
<xsd:element ref="DefineGroup"/>
<xsd:element ref="Menu"/>
</xsd:choice>
Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Frans Englich wrote:
On Monday 01 November 2004 13:26, Jeni Tennison wrote:
Hi Frans,
How do I achieve this -- allow multiple unbounded elements to be
freely mixed with each others and simple elements?
This is probably the most frequent of FAQs.
DTDs have a similar restriction, and the traditional approach is to
define the model using something like:
((include | group)*, kcfgfile, (include | group)*)
I have a similar problem again, but this time a DTD expression validates for
it. It looks like this:
<!ELEMENT Menu (title | Action | ActionList | Separator | WeakSeparator |
TearOffHandle | Merge | MergeLocal | DefineGroup | Menu )*>
My DTD knowledge is smaller than what I know about XML Schema, but to me that
reads like Menu may contain zero or more of those listed items, in any order.
I tried to replicate it in XML Schema(snipped and compacted):
<xsd:element name="Menu">
<xsd:complexType>
<xsd:all>
<xsd:element minOccurs="0" name="title" type="caption" />
<xsd:element ref="Action" maxOccurs="unbounded" />
<xsd:element ref="ActionList" maxOccurs="unbounded" />
<xsd:element minOccurs="0" maxOccurs="unbounded" name="TearOffHandle">
</xsd:element>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="DefineGroup">
</xsd:element>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="MergeLocal">
</xsd:element>
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="Separator" />
<xsd:element minOccurs="0" maxOccurs="unbounded"
ref="WeakSeparator" />
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="Menu" />
<xsd:element minOccurs="0" maxOccurs="unbounded" name="Merge" />
</xsd:all>
This obviously doesn't work since 'all' indicator and maxOccurs="unbounded" is
combined, but it illustrates what I want. Is it impossible to express such
constructs, which works in DTD, in XML Schema, or have I missed something?
Cheers,
Frans
Thread at a glance:
Previous Message by Date:
click to view message preview
Re: Combining maxOccurs="unbounded" with all indicator
On Monday 01 November 2004 13:26, Jeni Tennison wrote:
> Hi Frans,
>
> > How do I achieve this -- allow multiple unbounded elements to be
> > freely mixed with each others and simple elements?
>
> This is probably the most frequent of FAQs.
>
> DTDs have a similar restriction, and the traditional approach is to
> define the model using something like:
>
> ((include | group)*, kcfgfile, (include | group)*)
I have a similar problem again, but this time a DTD expression validates for
it. It looks like this:
<!ELEMENT Menu (title | Action | ActionList | Separator | WeakSeparator |
TearOffHandle | Merge | MergeLocal | DefineGroup | Menu )*>
My DTD knowledge is smaller than what I know about XML Schema, but to me that
reads like Menu may contain zero or more of those listed items, in any order.
I tried to replicate it in XML Schema(snipped and compacted):
<xsd:element name="Menu">
<xsd:complexType>
<xsd:all>
<xsd:element minOccurs="0" name="title" type="caption" />
<xsd:element ref="Action" maxOccurs="unbounded" />
<xsd:element ref="ActionList" maxOccurs="unbounded" />
<xsd:element minOccurs="0" maxOccurs="unbounded" name="TearOffHandle">
</xsd:element>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="DefineGroup">
</xsd:element>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="MergeLocal">
</xsd:element>
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="Separator" />
<xsd:element minOccurs="0" maxOccurs="unbounded"
ref="WeakSeparator" />
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="Menu" />
<xsd:element minOccurs="0" maxOccurs="unbounded" name="Merge" />
</xsd:all>
This obviously doesn't work since 'all' indicator and maxOccurs="unbounded" is
combined, but it illustrates what I want. Is it impossible to express such
constructs, which works in DTD, in XML Schema, or have I missed something?
Cheers,
Frans
Next Message by Date:
click to view message preview
Re: conditional occurrences of child elements
Hi Josef,
No, that is not possible in XML Schema.
Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
jozef.aerts@xxxxxxxxxxxxxx wrote:
Is it possible in XML-Schema to define the number of occurrences of an
element on the value of an attribute of its parent element ?
For example:
I have a parent element with name Person and attribute Gender.
Gender can only have the values 'Male' or 'Female'.
No problem sofar.
Now I want to define a subelement 'Pregant' of 'Person'.
The element 'Pregnant' should have no occurrences if the value of its
parent element attribute 'Gender' is 'Male'.
The element 'Pregnant' should have 1 occurrence if the value of its
parent element attribute 'Gender' is 'Female'.
Is it possible to define something like this in XML-Schema ?
Best regards
Jozef Aerts
Previous Message by Thread:
click to view message preview
Re: Combining maxOccurs="unbounded" with all indicator
On Monday 01 November 2004 13:26, Jeni Tennison wrote:
> Hi Frans,
>
> > How do I achieve this -- allow multiple unbounded elements to be
> > freely mixed with each others and simple elements?
>
> This is probably the most frequent of FAQs.
>
> DTDs have a similar restriction, and the traditional approach is to
> define the model using something like:
>
> ((include | group)*, kcfgfile, (include | group)*)
I have a similar problem again, but this time a DTD expression validates for
it. It looks like this:
<!ELEMENT Menu (title | Action | ActionList | Separator | WeakSeparator |
TearOffHandle | Merge | MergeLocal | DefineGroup | Menu )*>
My DTD knowledge is smaller than what I know about XML Schema, but to me that
reads like Menu may contain zero or more of those listed items, in any order.
I tried to replicate it in XML Schema(snipped and compacted):
<xsd:element name="Menu">
<xsd:complexType>
<xsd:all>
<xsd:element minOccurs="0" name="title" type="caption" />
<xsd:element ref="Action" maxOccurs="unbounded" />
<xsd:element ref="ActionList" maxOccurs="unbounded" />
<xsd:element minOccurs="0" maxOccurs="unbounded" name="TearOffHandle">
</xsd:element>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="DefineGroup">
</xsd:element>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="MergeLocal">
</xsd:element>
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="Separator" />
<xsd:element minOccurs="0" maxOccurs="unbounded"
ref="WeakSeparator" />
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="Menu" />
<xsd:element minOccurs="0" maxOccurs="unbounded" name="Merge" />
</xsd:all>
This obviously doesn't work since 'all' indicator and maxOccurs="unbounded" is
combined, but it illustrates what I want. Is it impossible to express such
constructs, which works in DTD, in XML Schema, or have I missed something?
Cheers,
Frans
Next Message by Thread:
click to view message preview
'Re: "Re: Comparison of values of anySimpleType"'
Hi,
Ahh, thanks for the hint; I did poke in XML Schema Part 2, and was too
blind to see this obvious statement in XML Schema Part 1.
Hmm, observing the changed behaviour in Xerces-J 2.6.2 - it seems to
dislike comparison with 'anySimpleType' now: does the XS world tend to
move to disallow comparison with 'anySimpleType' here?
If using IDCs: is the simple/complex ur-type assumed for nodes, for
which no declarations exist, if processed by skip/lax wildcards? Or are
IDC fields restricted to resolve to declared (or xsi:type) nodes only?
Thanks & regards,
Kasimier
noah_mendelsohn@xxxxxxxxxx wrote:
> From our brand, spanking new XML Schema 1.0 Second Edition Recommendation
> [1]:
> "The mapping from lexical space to value space is unspecified for items
> whose type definition is the ·simple ur-type definition·. Accordingly this
> specification does not constrain processors' behaviour in areas where this
> mapping is implicated, for example checking such items against
> enumerations, constructing default attributes or elements whose declared
> type definition is the ·simple ur-type definition·, checking identity
> constraints involving such items.
>
> Note: The Working Group expects to return to this area in a future version
> of this specification."
> Key/keyref are what the Recommendation calls Identity Constraints. So,
> this is a rare case where processors implementing different validation
> rules are all conforming.
>
> Noah
> [1]
> http://www.w3.org/TR/2004/PER-xmlschema-1-20040318/#Type_Definition_Summary
>
> --------------------------------------
> Noah Mendelsohn
> IBM Corporation
> One Rogers Street
> Cambridge, MA 02142
> 1-617-693-4036
> --------------------------------------
>
>
>
>
>
>
>
>
> Kasimier Buchcik <kbuchcik@xxxxxxxxxxxx>
> Sent by: xmlschema-dev-request@xxxxxx
> 10/20/04 07:45 AM
>
>
> To: <xmlschema-dev@xxxxxx>
> cc: (bcc: Noah Mendelsohn/Cambridge/IBM)
> Subject: Comparison of values of anySimpleType
>
>
>
> Hi,
>
> I have trouble understanding how 'anySimpleType' is handled if comparing
> values. Xerces and XSV seem to differ here.
>
> Identity-constraint example:
> (using Xerces-J 2.5.1, XSV 2.5-2, MSXML 4.0)
>
> <sequence>
> <element name="b" type="anySimpleType"/>
> <element name="c" type="float"/>
> </sequence>
>
> <b>1.0</b>
> <c>1.0</c>
>
> with the value of 'c' being a keyref to the key value of 'b'.
>
> Results: XSV and MSXML do not find the referenced key, Xerces does.
>
> if both types are 'float':
>
> Results: All tree validators find the referenced key.
>
> I cannot find a hint for 'anySimpleType' being not comparable with the
> primitive types. The PER for datatypes says:
>
> "anySimpleType is considered to have an unconstrained lexical space and
> a ·value space· consisting of the union of the ·value space·s of all the
> ·primitive· datatypes and the set of all lists of all members of the
> ·value space·s of all the ·primitive· datatypes."
>
> Further "4.2.1 equal" says:
>
> "if a datatype T' is ·derived· by ·restriction· from an atomic datatype
> T then the ·value space· of T' is a subset of the ·value space· of T.
> Values in the ·value space·s of T and T' can be compared according to
> the above rules "
>
> Can someone explain?
>
> Greetings,
>
> Kasimier
>