473,405 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Question about xsd:extension

Hi all,
I have a case where I have a element that can appear under multiple
elements
e.g.
<AppFunctions>
<UseTemplate name="1"/>
<MethodSet name="2">
<UseTemplate name="3" />
<MethodCall name="4" />
</MethodSet>
<MethodSet name="5">
<MethodCall name="6" />
</MethodSet>
<UseTemplate name="7" />
</AppFunctions>

I would like a way to define a root element which has just the
UseTemplate element and then derive 2 elements from it "AppFunctions"
and "MethodSet" which extend it to add further elements to it. This
elements in the derived elements need to unordered and can occur
multiple times. This is what I came up with:

<xs:complexType name="UIElementType">
<xs:choice maxOccurs="unbounded">
<xs:element name="UseTemplate" type="UseTemplateType" minOccurs="0"
maxOccurs="unbounded" />
</xs:choice>
</xs:complexType>

<xs:complexType name="AppFunctionType">
<xs:complexContent>
<xs:extension base="UIElementType">
<xs:choice maxOccurs="unbounded">
<xs:element name="MethodSet" type="MethodSetType"
maxOccurs="unbounded" />
</xs:choice>
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:complexType name="MethodSetType">
<xs:complexContent>
<xs:extension base="UIElementType">
<xs:choice maxOccurs="unbounded">
<xs:element name="MethodCall" type="MethodCallType" minOccurs="0"
maxOccurs="unbounded" />
</xs:choice>
<xs:attribute name="name" type="xs:string" use="required" />
</xs:extension>
</xs:complexContent>
</xs:complexType>

This definition is allowing me mutiple UseTemplate nodes directly under
AppFunctions but once I add a MethodSet node under AppFunctions, it
does not allow any UseTemplates anymore.

Thanx in advance,
Amol.

Mar 8 '06 #1
3 1726
Hi,

That is because the content type of the derived type contains a
sequence of the two choices, see 3.2.3 from
http://www.w3.org/TR/xmlschema-1/#key-efm
***
3.2.3 otherwise a pair of mixed or elementOnly (determined as per
clause 3.1.2.1 above) and a particle whose properties are as follows:

{min occurs}
1
{max occurs}
1
{term}
A model group whose {compositor} is sequence and whose {particles}
are the particle of the {content type} of the type definition
·resolved· to by the ·actual value· of the base [attribute]
followed by the ·effective content·.
***

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Mar 9 '06 #2
Is there any other way to get the behavior where the extension would
behave as a choice rather than sequence. The element I want to
"inherit" occurs under multiple elements so rather than define once
under each I was hoping to define it once in a parent element and
extend all the elements that need it from the parent element.

Thanx, Amol.

Mar 9 '06 #3
No, In XML Schema the model created by extension is sequence.
On possible approach is to place common content in a named group and
refer to that group from your complex types where you want that common
content.
Another one that will have a behaviour very close to what you want is
to define for instance an abstract element, let's say instruction and
define the content model using references to this element. Then you can
define actual non abstract elements that can substitute instruction.
The instruction element will be basically replaced in this way with a
choice of all the elements from its substiturion group.
Have a look at the XML Schema for XSLT 2.0, there you can find
something like I described above:
http://www.w3.org/TR/xslt20/#schema-for-xslt

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Mar 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gregg Williams | last post by:
Hi--I am having a problem designing a schema to fit my XML data, and I'm hoping that someone can help. Essentially, I have a schema in mind and two target vocabularies for it, where one vocabulary...
2
by: Sean Bright | last post by:
Hi there. I'm having a problem which I hope is a simple one... Any help would be appreciated. I think it has something to do with the way attributes are (or are not) inherited in schemas... ...
4
by: trexim | last post by:
It seems that .NET does not support xsd:extension and xsd:attribute. What is the alternative? Thanks,
3
by: man-in-nature | last post by:
Hello, I have already read several existing posts about xsd:extension, but do not find something useful to my test case. I have one xml file and one xsd file. I can use a simple command line...
8
by: aevans1108 | last post by:
Greetings I can't seem to inherit enumerated values from a globally defined type in my XML schema. XmlSchema.Compile() doesn't like it. Here's the schema. <?xml version="1.0"...
4
by: Mike Jansen | last post by:
Does anyone know why if I create a complexType based off another complexType using xsd:extension the attributes don't seem to be inherited? Is this a bug/non-implementation in the .NET Schema...
3
by: comic_rage | last post by:
I am trying to get my schema to look like this <xsd:extension base="MyExtension"> <xsd:attributeGroup ref="DocumentAttributes"> <xsd:annotation> <xsd:documentation>Notes</xsd:documentation>...
0
by: Amol | last post by:
Hi all, I have a case where I have a element that can appear under multiple elements e.g. <AppFunctions> <UseTemplate name="1"/> <MethodSet name="2"> <UseTemplate name="3" /> <MethodCall...
5
by: Kunal | last post by:
I'm unable to use the "xsd:all" tag in derived objects, in a hierarchical schema setup. For example, I have the following schema (that doesn't validate with XMLSpy): (UserOfDerived extends...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.