473,698 Members | 2,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "AppFunctio ns"
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:complexTy pe name="UIElement Type">
<xs:choice maxOccurs="unbo unded">
<xs:element name="UseTempla te" type="UseTempla teType" minOccurs="0"
maxOccurs="unbo unded" />
</xs:choice>
</xs:complexType>

<xs:complexTy pe name="AppFuncti onType">
<xs:complexCont ent>
<xs:extension base="UIElement Type">
<xs:choice maxOccurs="unbo unded">
<xs:element name="MethodSet " type="MethodSet Type"
maxOccurs="unbo unded" />
</xs:choice>
</xs:extension>
</xs:complexConte nt>
</xs:complexType>

<xs:complexTy pe name="MethodSet Type">
<xs:complexCont ent>
<xs:extension base="UIElement Type">
<xs:choice maxOccurs="unbo unded">
<xs:element name="MethodCal l" type="MethodCal lType" minOccurs="0"
maxOccurs="unbo unded" />
</xs:choice>
<xs:attribute name="name" type="xs:string " use="required" />
</xs:extension>
</xs:complexConte nt>
</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 1749
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
2715
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 is a subset of the other. I will describe one part of the schema to give you an idea of what my problem is. The "big" schema calls for 0 or more selector elements, each containing a (required) name attribute and simple character data, as...
2
3097
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... This is the content of my XML Schema (minus the schema tag): <xsd:complexType name="AType"> <xsd:attribute name="attr1" type="xsd:string" />
4
1672
by: trexim | last post by:
It seems that .NET does not support xsd:extension and xsd:attribute. What is the alternative? Thanks,
3
2058
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 (C#) program to validate the xml file against the xsd file without any error. The problem is that when I validate the same xml file within VisualStudio 2003, I got five errors, which are all related to xsd:extension. It seems that those "problem"...
8
6507
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" encoding="UTF-8" ?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
4
2027
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 editor and the XML validator? Thanks, Mike Jansen
3
2028
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> </xsd:annotation> </xsd:attributeGroup> </xsd:extension>
0
346
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 name="4" /> </MethodSet>
5
1793
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 Derived extends Base) <!-- Base.xsd --> .... <xsd:complexType name = "Base" abstract = "true"> <attribute name = "revision" type = "xsd:string"/>
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7740
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.