get min or max occurs [message #60210] |
Thu, 28 April 2005 15:21 |
Eclipse User |
|
|
|
Originally posted by: aaudevart.genigraph.fr
Hi,
I am trying to extract the min and max occurs but I don't know what
interface i need use to get the max and min occurence.
<xs:element name="child_name" type="xs:string" minOccurs="0"
maxOccurs="5"/>
Can somebody help me please?
Thanks.
|
|
|
Re: get min or max occurs [message #60234 is a reply to message #60210] |
Thu, 28 April 2005 15:31 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Alex,
A local element declaration or element reference gives rise to both an
XSDParticle and an XSDElementDeclaration and you should look for the min
and max on the particle.
Alex wrote:
> Hi,
>
> I am trying to extract the min and max occurs but I don't know what
> interface i need use to get the max and min occurence.
> <xs:element name="child_name" type="xs:string" minOccurs="0"
> maxOccurs="5"/>
>
> Can somebody help me please?
> Thanks.
>
|
|
|
Re: get min or max occurs [message #60258 is a reply to message #60234] |
Thu, 28 April 2005 15:59 |
Eclipse User |
|
|
|
Originally posted by: aaudevart.genigraph.fr
I find a method which return a XSDParticle :
XSDSimpleTypeDefinition aSimpleType
XSDParticle particle = aSimpleType.getComplexType();
but the particule is always null.
May be it isn't the right method.
Here is my xsd code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="persons">
<xs:complexType>
<xs:sequence>
<xs:element name="person" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="full_name" type="xs:string"/>
<xs:element name="child_name" type="xs:string"
minOccurs="0" maxOccurs="5"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Thanks.
|
|
|
Re: get min or max occurs [message #60280 is a reply to message #60258] |
Thu, 28 April 2005 16:33 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Alex,
This method applied to a simple type definition will return null; a
simple type does not have complex content. When applied to a complex
type, it will return the particle, as long as the type doesn't have
empty content or simple content, in which cases there is no particle.
Alex wrote:
> I find a method which return a XSDParticle :
>
> XSDSimpleTypeDefinition aSimpleType
> XSDParticle particle = aSimpleType.getComplexType();
>
> but the particule is always null.
> May be it isn't the right method.
>
> Here is my xsd code:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
>
> <xs:element name="persons">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="person" maxOccurs="unbounded">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="full_name" type="xs:string"/>
> <xs:element name="child_name" type="xs:string"
> minOccurs="0" maxOccurs="5"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> </xs:schema>
>
> Thanks.
>
>
>
>
>
|
|
|
Re: get min or max occurs [message #60304 is a reply to message #60280] |
Fri, 29 April 2005 07:29 |
Eclipse User |
|
|
|
Originally posted by: aaudevart.genigraph.fr
Hi,
In my case, I've got a simple type so how can i extract the min and max
occurs?
I understand that this : <xs:element name="full_name" type="xs:string"/>
is a simple type and this is a complex type : <xs:element name="full_name"
type="bobi"/>.
Is it exact?
Thanks
|
|
|
Re: get min or max occurs [message #60327 is a reply to message #60304] |
Fri, 29 April 2005 11:13 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Alex,
A simple type doesn't have min and max occurs. Both things you show
are element declarations. So I'm quite confused...
In your earlier example you had an element called "persons" with an
anonymous complex type, so given the element declaration for "persons"
you could do xsdElementDeclaration.getType().getComplexType() to get the
root particular of the element's type; you'll get null unless it is a
complex type with complex content. Walking this particle tree will get
you to the "person" element nested in that type.
Alex wrote:
> Hi,
>
> In my case, I've got a simple type so how can i extract the min and
> max occurs?
>
> I understand that this : <xs:element name="full_name"
> type="xs:string"/> is a simple type and this is a complex type :
> <xs:element name="full_name" type="bobi"/>.
>
> Is it exact?
> Thanks
>
>
|
|
|
Re: get min or max occurs [message #60348 is a reply to message #60327] |
Mon, 02 May 2005 08:55 |
Eclipse User |
|
|
|
Originally posted by: aaudevart.genigraph.fr
Hi,
Two possibilities, may be i don't understand what you explain to me or it
isn't working!
So if i want to extract the cardinality of "item" which are 0 and 5.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="toto" type="Items"/>
<xs:complexType name="Items">
<xs:sequence>
<xs:element name="item" minOccurs="0" maxOccurs="5">
<xs:complexType>
<xs:sequence>
<xs:element name="productName" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
I do that :
aComplexType is a XSDComplexTypeDefinition
So :
XSDParticle particle = aComplexType.getComplexType();
int min = particle.getMinOccurs()
int max = particle.getMaxOccurs()
But the problem is that min and max are always equals to 1 and 1.
Thanks for your help
|
|
|
Re: get min or max occurs [message #60371 is a reply to message #60348] |
Mon, 02 May 2005 10:29 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Alex,
You'll find the the top level particle of a complex type has a term that
is a sequence and that this sequence contains the particles you are
interested in. I.e., stop and think about how it would work if you have
two elements rather than just one in your complex type.
Alex wrote:
> Hi,
>
> Two possibilities, may be i don't understand what you explain to me or
> it isn't working!
>
> So if i want to extract the cardinality of "item" which are 0 and 5.
>
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
> <xs:element name="toto" type="Items"/>
> <xs:complexType name="Items">
> <xs:sequence>
> <xs:element name="item" minOccurs="0" maxOccurs="5">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="productName" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
>
> </xs:schema>
>
> I do that :
>
> aComplexType is a XSDComplexTypeDefinition
> So :
> XSDParticle particle = aComplexType.getComplexType();
> int min = particle.getMinOccurs()
> int max = particle.getMaxOccurs()
>
> But the problem is that min and max are always equals to 1 and 1.
>
> Thanks for your help
>
>
>
>
|
|
|
|
Re: get min or max occurs [message #595214 is a reply to message #60210] |
Thu, 28 April 2005 15:31 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Alex,
A local element declaration or element reference gives rise to both an
XSDParticle and an XSDElementDeclaration and you should look for the min
and max on the particle.
Alex wrote:
> Hi,
>
> I am trying to extract the min and max occurs but I don't know what
> interface i need use to get the max and min occurence.
> <xs:element name="child_name" type="xs:string" minOccurs="0"
> maxOccurs="5"/>
>
> Can somebody help me please?
> Thanks.
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: get min or max occurs [message #595235 is a reply to message #60258] |
Thu, 28 April 2005 16:33 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Alex,
This method applied to a simple type definition will return null; a
simple type does not have complex content. When applied to a complex
type, it will return the particle, as long as the type doesn't have
empty content or simple content, in which cases there is no particle.
Alex wrote:
> I find a method which return a XSDParticle :
>
> XSDSimpleTypeDefinition aSimpleType
> XSDParticle particle = aSimpleType.getComplexType();
>
> but the particule is always null.
> May be it isn't the right method.
>
> Here is my xsd code:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
>
> <xs:element name="persons">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="person" maxOccurs="unbounded">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="full_name" type="xs:string"/>
> <xs:element name="child_name" type="xs:string"
> minOccurs="0" maxOccurs="5"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> </xs:schema>
>
> Thanks.
>
>
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: get min or max occurs [message #595259 is a reply to message #60304] |
Fri, 29 April 2005 11:13 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Alex,
A simple type doesn't have min and max occurs. Both things you show
are element declarations. So I'm quite confused...
In your earlier example you had an element called "persons" with an
anonymous complex type, so given the element declaration for "persons"
you could do xsdElementDeclaration.getType().getComplexType() to get the
root particular of the element's type; you'll get null unless it is a
complex type with complex content. Walking this particle tree will get
you to the "person" element nested in that type.
Alex wrote:
> Hi,
>
> In my case, I've got a simple type so how can i extract the min and
> max occurs?
>
> I understand that this : <xs:element name="full_name"
> type="xs:string"/> is a simple type and this is a complex type :
> <xs:element name="full_name" type="bobi"/>.
>
> Is it exact?
> Thanks
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: get min or max occurs [message #595283 is a reply to message #60348] |
Mon, 02 May 2005 10:29 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Alex,
You'll find the the top level particle of a complex type has a term that
is a sequence and that this sequence contains the particles you are
interested in. I.e., stop and think about how it would work if you have
two elements rather than just one in your complex type.
Alex wrote:
> Hi,
>
> Two possibilities, may be i don't understand what you explain to me or
> it isn't working!
>
> So if i want to extract the cardinality of "item" which are 0 and 5.
>
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
> <xs:element name="toto" type="Items"/>
> <xs:complexType name="Items">
> <xs:sequence>
> <xs:element name="item" minOccurs="0" maxOccurs="5">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="productName" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
>
> </xs:schema>
>
> I do that :
>
> aComplexType is a XSDComplexTypeDefinition
> So :
> XSDParticle particle = aComplexType.getComplexType();
> int min = particle.getMinOccurs()
> int max = particle.getMaxOccurs()
>
> But the problem is that min and max are always equals to 1 and 1.
>
> Thanks for your help
>
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.04508 seconds