xs:all reuse

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

xs:all reuse

Karl Stubsjoen
I have a complextype, which looks sort of like this:

<xs:complexType name="my complext type">
  <xs:all>
    <xs:element name="item1"/>
    <xs:element name="item2"/>
    <xs:element name="item3"/>
   <xs:element name="group">
      <!--
        this group should refer to to this set of xs:all elements
        allowing a child, child, child ... relationship
      -->
  </xs:element>
  </xs:all>
  <xs:attributeGroup ref="common"/>
  <xs:attribute name="title"/>
  </xs:attribute name="name"/>
</xs:complexType>

 Maybe not possible, but trying to understand. How could I accomplish
this?  So at the top most level I have an element defined as the type
"my complex type", which result in this element with attributes: <all
common attributes> + title, and name and the elements: item1, item2,
item3 and group.  I guess I don't understand how to define the set of
<xs:all> items as a type which I can then reuse to define  the element
group.

Thanks,
Karl..


Reply | Threaded
Open this post in threaded view
|

Re: xs:all reuse

Kevin Braun
Hi Karl,

Are you aware that you can define named groups for reuse using
xs:group?  It sounds like that is what you are looking for.

So, you would do something like:
<!-- Define a named group that you can reuse-->
<xs:group name="MyGroup">
<xs:all>
<xs:element name="item1"/>
<xs:element name="item2"/>
<xs:element name="item3"/>
<xs:element name="group" type="TypeForGroupElement"/>
</xs:all>
</xs:group>

<!-- Define a type for your "group" element.  It uses the named group.  
No attributes. -->
<xs:complexType name="TypeForGroupElement">
<xs:group ref="MyGroup">
</xs:complexType>

<!-- Define your original type using the named group -->
<xs:complexType name="MyType">
<xs:group ref="MyGroup"/>
<xs:attributeGroup ref="common"/>
<xs:attribute name="title"/>
<xs:attribute name="name"/>
</xs:complexType>

HTH,
Kevin

--
Objective Systems, Inc.
REAL WORLD ASN.1 AND XML SOLUTIONS
http://www.obj-sys.com



On 6/1/2010 12:59 PM, Karl Stubsjoen wrote:

> I have a complextype, which looks sort of like this:
>
> <xs:complexType name="my complext type">
>    <xs:all>
>      <xs:element name="item1"/>
>      <xs:element name="item2"/>
>      <xs:element name="item3"/>
>     <xs:element name="group">
>        <!--
>          this group should refer to to this set of xs:all elements
>          allowing a child, child, child ... relationship
>        -->
>    </xs:element>
>    </xs:all>
>    <xs:attributeGroup ref="common"/>
>    <xs:attribute name="title"/>
>    </xs:attribute name="name"/>
> </xs:complexType>
>
>   Maybe not possible, but trying to understand. How could I accomplish
> this?  So at the top most level I have an element defined as the type
> "my complex type", which result in this element with attributes:<all
> common attributes>  + title, and name and the elements: item1, item2,
> item3 and group.  I guess I don't understand how to define the set of
> <xs:all>  items as a type which I can then reuse to define  the element
> group.
>
> Thanks,
> Karl..
>
>
>
>    

Reply | Threaded
Open this post in threaded view
|

Re: xs:all reuse

Karl Stubsjoen
Thank you, that worked.

On Wed, Jun 2, 2010 at 6:13 AM, Kevin Braun <[hidden email]> wrote:

> Hi Karl,
>
> Are you aware that you can define named groups for reuse using xs:group?  It
> sounds like that is what you are looking for.
>
> So, you would do something like:
> <!-- Define a named group that you can reuse-->
> <xs:group name="MyGroup">
> <xs:all>
> <xs:element name="item1"/>
> <xs:element name="item2"/>
> <xs:element name="item3"/>
> <xs:element name="group" type="TypeForGroupElement"/>
> </xs:all>
> </xs:group>
>
> <!-- Define a type for your "group" element.  It uses the named group.  No
> attributes. -->
> <xs:complexType name="TypeForGroupElement">
> <xs:group ref="MyGroup">
> </xs:complexType>
>
> <!-- Define your original type using the named group -->
> <xs:complexType name="MyType">
> <xs:group ref="MyGroup"/>
> <xs:attributeGroup ref="common"/>
> <xs:attribute name="title"/>
> <xs:attribute name="name"/>
> </xs:complexType>
>
> HTH,
> Kevin
>
> --
> Objective Systems, Inc.
> REAL WORLD ASN.1 AND XML SOLUTIONS
> http://www.obj-sys.com
>
>
>
> On 6/1/2010 12:59 PM, Karl Stubsjoen wrote:
>>
>> I have a complextype, which looks sort of like this:
>>
>> <xs:complexType name="my complext type">
>>   <xs:all>
>>     <xs:element name="item1"/>
>>     <xs:element name="item2"/>
>>     <xs:element name="item3"/>
>>    <xs:element name="group">
>>       <!--
>>         this group should refer to to this set of xs:all elements
>>         allowing a child, child, child ... relationship
>>       -->
>>   </xs:element>
>>   </xs:all>
>>   <xs:attributeGroup ref="common"/>
>>   <xs:attribute name="title"/>
>>   </xs:attribute name="name"/>
>> </xs:complexType>
>>
>>  Maybe not possible, but trying to understand. How could I accomplish
>> this?  So at the top most level I have an element defined as the type
>> "my complex type", which result in this element with attributes:<all
>> common attributes>  + title, and name and the elements: item1, item2,
>> item3 and group.  I guess I don't understand how to define the set of
>> <xs:all>  items as a type which I can then reuse to define  the element
>> group.
>>
>> Thanks,
>> Karl..
>>
>>
>>
>>
>