Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > how to use restrictions and extensions in XSD simultanously

Reply
Thread Tools

how to use restrictions and extensions in XSD simultanously

 
 
Dmitry Kulinich
Guest
Posts: n/a
 
      02-19-2007
Guys! I've got 1 more small problem with XSD. It simple and good, but
sometimes disappointing.
For example we have 3 <TH> tags - only text and 1 attribute.
Then we need <restriction>-<enumeration> to set all <th>'s text values, but
also <extension> to add 1 attribute
How to do it simultanously inside og 1 element?
Here is simple code in XSD:
<xsd:element name="TH" >

<xsd:complexType>

<xsd:simpleContent>

<xsd:extension base="xsd:string">

<!--xsd:restriction base="xsd:string">

<xsd:enumeration value="Process ID"/>

<xsd:enumeration value="Activity ID"/>

<xsd:enumeration value="Instance ID"/>

<xsd:enumeration value="Process Description"/>

</xsd:restriction-->

<xsd:attribute name="style" type="xsd:string" />

</xsd:extension>


</xsd:simpleContent>


</xsd:complexType>

</xsd:element>


--
Thank you,
De Cool,
EPE


 
Reply With Quote
 
 
 
 
usenet@tech-know-ware.com
Guest
Posts: n/a
 
      02-20-2007
On 19 Feb, 21:48, "Dmitry Kulinich" <d...@isd.dp.ua> wrote:

> For example we have 3 <TH> tags - only text and 1 attribute.
> Then we need <restriction>-<enumeration> to set all <th>'s text values, but
> also <extension> to add 1 attribute


In XSD schema you have to do it in two stages. Define the body type
of the TH element (as a simple type), and then extend it to add the
attribute. e.g.:

<xsd:simpleType name="THType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Process ID"/>
<xsd:enumeration value="Activity ID"/>
<xsd:enumeration value="Instance ID"/>
<xsd:enumeration value="Process Description"/>
</xsd:restriction>
</xsd:simpleType>

<xsd:element name="TH" >
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="THType">
<xsd:attribute name="style" type="xsd:string" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>

HTH,

Pete.
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx
(or http://www.xml2cpp.com)
=============================================

 
Reply With Quote
 
 
 
 
usenet@tech-know-ware.com
Guest
Posts: n/a
 
      02-20-2007
Original Message From: "Dmitry Kulinich"
>
> Thank you, Pete! It's really simple )))
> Could you answer one more question please - how to define few <td> tags with
> different types
> (means - tags with the same name but with the different type. A've tried to
> set node type in restrictions but it doesn't works )



If the types are all simple types, then you can use schema's xs:union
construct. e.g.:

<xs:simpleType name="TDType">
<xs:union memberTypes="xs:float xs:int xs:string"/>
</xs:simpleType>

Normally you would put the most restricted type first, followed by
progressively less restricted types. i.e. all integers could be
represented in a string, but not all strings are valid integers.

If you want different complex types, thn I'm afraid you are out of
luck with XSD schema as it is defined today!

HTH,

Pete.
--
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx
(or http://www.xml2cpp.com)
=============================================

 
Reply With Quote
 
usenet@tech-know-ware.com
Guest
Posts: n/a
 
      02-20-2007
On 20 Feb, 15:29, use...@tech-know-ware.com wrote:
> Original Message From: "Dmitry Kulinich"
>
> > Thank you, Pete! It's really simple )))
> > Could you answer one more question please - how to define few <td> tags with
> > different types
> > (means - tags with the same name but with the different type. A've tried to
> > set node type in restrictions but it doesn't works )

>
> If the types are all simple types, then you can use schema's xs:union
> construct. e.g.:
>
> <xs:simpleType name="TDType">
> <xs:union memberTypes="xs:float xs:int xs:string"/>
> </xs:simpleType>
>
> Normally you would put the most restricted type first, followed by
> progressively less restricted types. i.e. all integers could be
> represented in a string, but not all strings are valid integers.


Ooops - which means I should flip xs:int and xs:float around! e.g.

<xs:simpleType name="TDType">
<xs:union memberTypes="xs:int xs:float xs:string"/>
</xs:simpleType>

Just testing!!!

Pete.
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx
(or http://www.xml2cpp.com)
=============================================



 
Reply With Quote
 
Dmitry Kulinich
Guest
Posts: n/a
 
      02-21-2007
unfortunately I needed this solution 4 the complex type
anyhow, thank you very mush!!!
<> wrote in message
news: ps.com...
> On 20 Feb, 15:29, use...@tech-know-ware.com wrote:
>> Original Message From: "Dmitry Kulinich"
>>
>> > Thank you, Pete! It's really simple )))
>> > Could you answer one more question please - how to define few <td> tags
>> > with
>> > different types
>> > (means - tags with the same name but with the different type. A've
>> > tried to
>> > set node type in restrictions but it doesn't works )

>>
>> If the types are all simple types, then you can use schema's xs:union
>> construct. e.g.:
>>
>> <xs:simpleType name="TDType">
>> <xs:union memberTypes="xs:float xs:int xs:string"/>
>> </xs:simpleType>
>>
>> Normally you would put the most restricted type first, followed by
>> progressively less restricted types. i.e. all integers could be
>> represented in a string, but not all strings are valid integers.

>
> Ooops - which means I should flip xs:int and xs:float around! e.g.
>
> <xs:simpleType name="TDType">
> <xs:union memberTypes="xs:int xs:float xs:string"/>
> </xs:simpleType>
>
> Just testing!!!
>
> Pete.
> =============================================
> Pete Cordell
> Tech-Know-Ware Ltd
> for XML to C++ data binding visit
> http://www.tech-know-ware.com/lmx
> (or http://www.xml2cpp.com)
> =============================================
>
>
>



 
Reply With Quote
 
usenet@tech-know-ware.com
Guest
Posts: n/a
 
      02-21-2007
On 21 Feb, 08:31, "Dmitry Kulinich" <d...@isd.dp.ua> wrote:
> unfortunately I needed this solution 4 the complex type
> anyhow, thank you very mush!!!
>
> >> Original Message From: "Dmitry Kulinich"

>
> >> > Thank you, Pete! It's really simple )))
> >> > Could you answer one more question please - how to define few <td> tags
> >> > with
> >> > different types
> >> > (means - tags with the same name but with the different type. A've
> >> > tried to
> >> > set node type in restrictions but it doesn't works )


Then I'm afraid, as far as XSD schema is concerned, you are left with
defining the superset of all the types.

Some people add schematron constraints to the XSD definition to select
the correct forms at runtime, but I'm not sure many tools support that
approach.

Relax-NG, an alternative schema language, has support for this sort of
thing, but I'm not sure how widely supported that is either (libxml2
has some support for it).

HTH,

Pete.
--
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx
(or http://www.xml2cpp.com)
=============================================

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
XSD restrictions/extensions Arinté XML 0 12-18-2008 03:51 PM
XSD restrictions - both string and numerical voorth XML 4 02-12-2008 03:18 PM
Restrictions in XSD TIANA XML 0 12-07-2004 09:38 PM
How to execute a aspx page more than once simultanously? =?Utf-8?B?U2l2YXJhbWFuLlM=?= ASP .Net 5 10-15-2004 01:19 AM



Advertisments