473,811 Members | 2,586 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 1757
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
2728
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
3109
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
1675
by: trexim | last post by:
It seems that .NET does not support xsd:extension and xsd:attribute. What is the alternative? Thanks,
3
2063
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
6512
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
2037
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
2032
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
1795
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
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10648
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
10389
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...
1
10402
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6890
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();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3018
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.