Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Facets retrieving - getFacetContents
Facets retrieving - getFacetContents [message #75338] Mon, 25 August 2008 02:11 Go to next message
Muhamad Nazir is currently offline Muhamad NazirFriend
Messages: 24
Registered: July 2009
Junior Member
Hi Ed and all,

I would like to know, what's the best way in retrieving facets. I noticed
a thread saying that we should use getFacetContents but which one should I
use in order to easily retrieve the facets, faster and better. Is it using
SimpleTypeDefinition or TypeDefinition directly?

I have something like this:
<!-- xsd snippet starts here -->
<xsd:complexType name="orderType">
<xsd:sequence>
<xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
<!-- xsd snippet ends here -->

//java code starts here
XSDParticle particle = (XSDParticle)obj;
XSDElementDeclaration element = (XSDElementDeclaration)
particle.getContent();

if(null != element.getTypeDefinition()) {
XSDTypeDefinition typeDef = element.getTypeDefinition();
XSDSimpleTypeDefinition simpleTypeDef = null;

if(null != typeDef.getSimpleType()) {
simpleTypeDef = typeDef.getSimpleType();
// this is the question:
//should I use this simpleTypeDef here???? or is there any simpler
solution
}

}

Thanks.
~Nazir~
Re: Facets retrieving - getFacetContents [message #75366 is a reply to message #75338] Mon, 25 August 2008 02:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Nazir,

Comments below.

Muhamad Nazir Samsudin wrote:
> Hi Ed and all,
>
> I would like to know, what's the best way in retrieving facets. I
> noticed a thread saying that we should use getFacetContents but which
> one should I use in order to easily retrieve the facets, faster and
> better. Is it using SimpleTypeDefinition or TypeDefinition directly?
It really comes down to what you want them for... More likely you want
to use getFacets to get all the facets of all the type hierarchy merged
nicely to give the ones that are applicable...
>
> I have something like this:
> <!-- xsd snippet starts here -->
> <xsd:complexType name="orderType">
> <xsd:sequence>
> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
> </xsd:sequence>
> </xsd:complexType>
> <!-- xsd snippet ends here -->
>
> //java code starts here
> XSDParticle particle = (XSDParticle)obj;
> XSDElementDeclaration element = (XSDElementDeclaration)
> particle.getContent();
>
> if(null != element.getTypeDefinition()) {
> XSDTypeDefinition typeDef = element.getTypeDefinition();
> XSDSimpleTypeDefinition simpleTypeDef = null;
>
> if(null != typeDef.getSimpleType()) {
> simpleTypeDef = typeDef.getSimpleType();
> // this is the question:
> //should I use this simpleTypeDef here???? or is there any simpler
> solution
Yes, you should use the simple type definition. They're the only things
with facets.
> }
> }
>
> Thanks.
> ~Nazir~
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Facets retrieving - getFacetContents [message #75381 is a reply to message #75366] Mon, 25 August 2008 06:41 Go to previous messageGo to next message
Muhamad Nazir is currently offline Muhamad NazirFriend
Messages: 24
Registered: July 2009
Junior Member
Thanks for the quick response, Ed.

Just another one, I noticed that when I was trying to get this using
simpleType:
<xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
it kinda gave me these facets:
fractionDigits='0', pattern='[\-+]?[0-9]+'

Any idea why I got these facets?
Thanks again.
~Nazir~

Ed Merks wrote:

> Nazir,

> Comments below.

> Muhamad Nazir Samsudin wrote:
>> Hi Ed and all,
>>
>> I would like to know, what's the best way in retrieving facets. I
>> noticed a thread saying that we should use getFacetContents but which
>> one should I use in order to easily retrieve the facets, faster and
>> better. Is it using SimpleTypeDefinition or TypeDefinition directly?
> It really comes down to what you want them for... More likely you want
> to use getFacets to get all the facets of all the type hierarchy merged
> nicely to give the ones that are applicable...
>>
>> I have something like this:
>> <!-- xsd snippet starts here -->
>> <xsd:complexType name="orderType">
>> <xsd:sequence>
>> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
>> </xsd:sequence>
>> </xsd:complexType>
>> <!-- xsd snippet ends here -->
>>
>> //java code starts here
>> XSDParticle particle = (XSDParticle)obj;
>> XSDElementDeclaration element = (XSDElementDeclaration)
>> particle.getContent();
>>
>> if(null != element.getTypeDefinition()) {
>> XSDTypeDefinition typeDef = element.getTypeDefinition();
>> XSDSimpleTypeDefinition simpleTypeDef = null;
>>
>> if(null != typeDef.getSimpleType()) {
>> simpleTypeDef = typeDef.getSimpleType();
>> // this is the question:
>> //should I use this simpleTypeDef here???? or is there any simpler
>> solution
> Yes, you should use the simple type definition. They're the only things
> with facets.
>> }
>> }
>>
>> Thanks.
>> ~Nazir~
>>
>>
Re: Facets retrieving - getFacetContents [message #75399 is a reply to message #75381] Mon, 25 August 2008 13:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Nazir,

Comments below.

Muhamad Nazir Samsudin wrote:
> Thanks for the quick response, Ed.
>
> Just another one, I noticed that when I was trying to get this using
> simpleType:
> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
> it kinda gave me these facets:
> fractionDigits='0', pattern='[\-+]?[0-9]+'
>
> Any idea why I got these facets?
Yes. The xsd:integer type is defined in the XMLSchema.xsd and it's
definition there, along with the definitions of the rest of the type up
its type hierarchy define these facets.
> Thanks again.
> ~Nazir~
>
> Ed Merks wrote:
>
>> Nazir,
>
>> Comments below.
>
>> Muhamad Nazir Samsudin wrote:
>>> Hi Ed and all,
>>>
>>> I would like to know, what's the best way in retrieving facets. I
>>> noticed a thread saying that we should use getFacetContents but
>>> which one should I use in order to easily retrieve the facets,
>>> faster and better. Is it using SimpleTypeDefinition or
>>> TypeDefinition directly?
>> It really comes down to what you want them for... More likely you
>> want to use getFacets to get all the facets of all the type hierarchy
>> merged nicely to give the ones that are applicable...
>>>
>>> I have something like this:
>>> <!-- xsd snippet starts here -->
>>> <xsd:complexType name="orderType">
>>> <xsd:sequence>
>>> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
>>> </xsd:sequence>
>>> </xsd:complexType>
>>> <!-- xsd snippet ends here -->
>>>
>>> //java code starts here
>>> XSDParticle particle = (XSDParticle)obj;
>>> XSDElementDeclaration element = (XSDElementDeclaration)
>>> particle.getContent();
>>>
>>> if(null != element.getTypeDefinition()) {
>>> XSDTypeDefinition typeDef = element.getTypeDefinition();
>>> XSDSimpleTypeDefinition simpleTypeDef = null;
>>>
>>> if(null != typeDef.getSimpleType()) {
>>> simpleTypeDef = typeDef.getSimpleType();
>>> // this is the question:
>>> //should I use this simpleTypeDef here???? or is there any
>>> simpler solution
>> Yes, you should use the simple type definition. They're the only
>> things with facets.
>>> }
>>> }
>>>
>>> Thanks.
>>> ~Nazir~
>>>
>>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Facets retrieving - getFacetContents [message #75417 is a reply to message #75399] Mon, 25 August 2008 23:52 Go to previous messageGo to next message
Muhamad Nazir is currently offline Muhamad NazirFriend
Messages: 24
Registered: July 2009
Junior Member
Ed,

In this case, even though I didn't specify any of my facets related to
this integer, getFacetContents will always get the defined facets in
XMLSchema.xsd? I bet other types too right?

Zillion thanks again,
~Nazir~

Ed Merks wrote:

> Nazir,

> Comments below.

> Muhamad Nazir Samsudin wrote:
>> Thanks for the quick response, Ed.
>>
>> Just another one, I noticed that when I was trying to get this using
>> simpleType:
>> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
>> it kinda gave me these facets:
>> fractionDigits='0', pattern='[-+]?[0-9]+'
>>
>> Any idea why I got these facets?
> Yes. The xsd:integer type is defined in the XMLSchema.xsd and it's
> definition there, along with the definitions of the rest of the type up
> its type hierarchy define these facets.
>> Thanks again.
>> ~Nazir~
>>
>> Ed Merks wrote:
>>
>>> Nazir,
>>
>>> Comments below.
>>
>>> Muhamad Nazir Samsudin wrote:
>>>> Hi Ed and all,
>>>>
>>>> I would like to know, what's the best way in retrieving facets. I
>>>> noticed a thread saying that we should use getFacetContents but
>>>> which one should I use in order to easily retrieve the facets,
>>>> faster and better. Is it using SimpleTypeDefinition or
>>>> TypeDefinition directly?
>>> It really comes down to what you want them for... More likely you
>>> want to use getFacets to get all the facets of all the type hierarchy
>>> merged nicely to give the ones that are applicable...
>>>>
>>>> I have something like this:
>>>> <!-- xsd snippet starts here -->
>>>> <xsd:complexType name="orderType">
>>>> <xsd:sequence>
>>>> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
>>>> </xsd:sequence>
>>>> </xsd:complexType>
>>>> <!-- xsd snippet ends here -->
>>>>
>>>> //java code starts here
>>>> XSDParticle particle = (XSDParticle)obj;
>>>> XSDElementDeclaration element = (XSDElementDeclaration)
>>>> particle.getContent();
>>>>
>>>> if(null != element.getTypeDefinition()) {
>>>> XSDTypeDefinition typeDef = element.getTypeDefinition();
>>>> XSDSimpleTypeDefinition simpleTypeDef = null;
>>>>
>>>> if(null != typeDef.getSimpleType()) {
>>>> simpleTypeDef = typeDef.getSimpleType();
>>>> // this is the question:
>>>> //should I use this simpleTypeDef here???? or is there any
>>>> simpler solution
>>> Yes, you should use the simple type definition. They're the only
>>> things with facets.
>>>> }
>>>> }
>>>>
>>>> Thanks.
>>>> ~Nazir~
>>>>
>>>>
>>
>>
Re: Facets retrieving - getFacetContents [message #75434 is a reply to message #75417] Tue, 26 August 2008 06:03 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Nazir,

The getFacets method returns the facets accumulated from the entire type
hierarchy including the part that's in the XMLSchema.xsd; these are the
facets that apply for any instance of that type. The getFacetContents
returns only the facets defined exactly on the specific type you're on.


Muhamad Nazir Samsudin wrote:
> Ed,
> In this case, even though I didn't specify any of my facets related to
> this integer, getFacetContents will always get the defined facets in
> XMLSchema.xsd? I bet other types too right?
>
> Zillion thanks again,
> ~Nazir~
>
> Ed Merks wrote:
>
>> Nazir,
>
>> Comments below.
>
>> Muhamad Nazir Samsudin wrote:
>>> Thanks for the quick response, Ed.
>>>
>>> Just another one, I noticed that when I was trying to get this using
>>> simpleType:
>>> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
>>> it kinda gave me these facets:
>>> fractionDigits='0', pattern='[-+]?[0-9]+'
>>>
>>> Any idea why I got these facets?
>> Yes. The xsd:integer type is defined in the XMLSchema.xsd and it's
>> definition there, along with the definitions of the rest of the type
>> up its type hierarchy define these facets.
>>> Thanks again.
>>> ~Nazir~
>>>
>>> Ed Merks wrote:
>>>
>>>> Nazir,
>>>
>>>> Comments below.
>>>
>>>> Muhamad Nazir Samsudin wrote:
>>>>> Hi Ed and all,
>>>>>
>>>>> I would like to know, what's the best way in retrieving facets. I
>>>>> noticed a thread saying that we should use getFacetContents but
>>>>> which one should I use in order to easily retrieve the facets,
>>>>> faster and better. Is it using SimpleTypeDefinition or
>>>>> TypeDefinition directly?
>>>> It really comes down to what you want them for... More likely you
>>>> want to use getFacets to get all the facets of all the type
>>>> hierarchy merged nicely to give the ones that are applicable...
>>>>>
>>>>> I have something like this:
>>>>> <!-- xsd snippet starts here -->
>>>>> <xsd:complexType name="orderType">
>>>>> <xsd:sequence>
>>>>> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
>>>>> </xsd:sequence>
>>>>> </xsd:complexType>
>>>>> <!-- xsd snippet ends here -->
>>>>>
>>>>> //java code starts here
>>>>> XSDParticle particle = (XSDParticle)obj;
>>>>> XSDElementDeclaration element = (XSDElementDeclaration)
>>>>> particle.getContent();
>>>>>
>>>>> if(null != element.getTypeDefinition()) {
>>>>> XSDTypeDefinition typeDef = element.getTypeDefinition();
>>>>> XSDSimpleTypeDefinition simpleTypeDef = null;
>>>>>
>>>>> if(null != typeDef.getSimpleType()) {
>>>>> simpleTypeDef = typeDef.getSimpleType();
>>>>> // this is the question:
>>>>> //should I use this simpleTypeDef here???? or is there any
>>>>> simpler solution
>>>> Yes, you should use the simple type definition. They're the only
>>>> things with facets.
>>>>> }
>>>>> }
>>>>>
>>>>> Thanks.
>>>>> ~Nazir~
>>>>>
>>>>>
>>>
>>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Facets retrieving - getFacetContents [message #603241 is a reply to message #75338] Mon, 25 August 2008 02:32 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Nazir,

Comments below.

Muhamad Nazir Samsudin wrote:
> Hi Ed and all,
>
> I would like to know, what's the best way in retrieving facets. I
> noticed a thread saying that we should use getFacetContents but which
> one should I use in order to easily retrieve the facets, faster and
> better. Is it using SimpleTypeDefinition or TypeDefinition directly?
It really comes down to what you want them for... More likely you want
to use getFacets to get all the facets of all the type hierarchy merged
nicely to give the ones that are applicable...
>
> I have something like this:
> <!-- xsd snippet starts here -->
> <xsd:complexType name="orderType">
> <xsd:sequence>
> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
> </xsd:sequence>
> </xsd:complexType>
> <!-- xsd snippet ends here -->
>
> //java code starts here
> XSDParticle particle = (XSDParticle)obj;
> XSDElementDeclaration element = (XSDElementDeclaration)
> particle.getContent();
>
> if(null != element.getTypeDefinition()) {
> XSDTypeDefinition typeDef = element.getTypeDefinition();
> XSDSimpleTypeDefinition simpleTypeDef = null;
>
> if(null != typeDef.getSimpleType()) {
> simpleTypeDef = typeDef.getSimpleType();
> // this is the question:
> //should I use this simpleTypeDef here???? or is there any simpler
> solution
Yes, you should use the simple type definition. They're the only things
with facets.
> }
> }
>
> Thanks.
> ~Nazir~
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Facets retrieving - getFacetContents [message #603247 is a reply to message #75366] Mon, 25 August 2008 06:41 Go to previous message
Muhamad Nazir is currently offline Muhamad NazirFriend
Messages: 24
Registered: July 2009
Junior Member
Thanks for the quick response, Ed.

Just another one, I noticed that when I was trying to get this using
simpleType:
<xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
it kinda gave me these facets:
fractionDigits='0', pattern='[\-+]?[0-9]+'

Any idea why I got these facets?
Thanks again.
~Nazir~

Ed Merks wrote:

> Nazir,

> Comments below.

> Muhamad Nazir Samsudin wrote:
>> Hi Ed and all,
>>
>> I would like to know, what's the best way in retrieving facets. I
>> noticed a thread saying that we should use getFacetContents but which
>> one should I use in order to easily retrieve the facets, faster and
>> better. Is it using SimpleTypeDefinition or TypeDefinition directly?
> It really comes down to what you want them for... More likely you want
> to use getFacets to get all the facets of all the type hierarchy merged
> nicely to give the ones that are applicable...
>>
>> I have something like this:
>> <!-- xsd snippet starts here -->
>> <xsd:complexType name="orderType">
>> <xsd:sequence>
>> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
>> </xsd:sequence>
>> </xsd:complexType>
>> <!-- xsd snippet ends here -->
>>
>> //java code starts here
>> XSDParticle particle = (XSDParticle)obj;
>> XSDElementDeclaration element = (XSDElementDeclaration)
>> particle.getContent();
>>
>> if(null != element.getTypeDefinition()) {
>> XSDTypeDefinition typeDef = element.getTypeDefinition();
>> XSDSimpleTypeDefinition simpleTypeDef = null;
>>
>> if(null != typeDef.getSimpleType()) {
>> simpleTypeDef = typeDef.getSimpleType();
>> // this is the question:
>> //should I use this simpleTypeDef here???? or is there any simpler
>> solution
> Yes, you should use the simple type definition. They're the only things
> with facets.
>> }
>> }
>>
>> Thanks.
>> ~Nazir~
>>
>>
Re: Facets retrieving - getFacetContents [message #603249 is a reply to message #75381] Mon, 25 August 2008 13:25 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Nazir,

Comments below.

Muhamad Nazir Samsudin wrote:
> Thanks for the quick response, Ed.
>
> Just another one, I noticed that when I was trying to get this using
> simpleType:
> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
> it kinda gave me these facets:
> fractionDigits='0', pattern='[\-+]?[0-9]+'
>
> Any idea why I got these facets?
Yes. The xsd:integer type is defined in the XMLSchema.xsd and it's
definition there, along with the definitions of the rest of the type up
its type hierarchy define these facets.
> Thanks again.
> ~Nazir~
>
> Ed Merks wrote:
>
>> Nazir,
>
>> Comments below.
>
>> Muhamad Nazir Samsudin wrote:
>>> Hi Ed and all,
>>>
>>> I would like to know, what's the best way in retrieving facets. I
>>> noticed a thread saying that we should use getFacetContents but
>>> which one should I use in order to easily retrieve the facets,
>>> faster and better. Is it using SimpleTypeDefinition or
>>> TypeDefinition directly?
>> It really comes down to what you want them for... More likely you
>> want to use getFacets to get all the facets of all the type hierarchy
>> merged nicely to give the ones that are applicable...
>>>
>>> I have something like this:
>>> <!-- xsd snippet starts here -->
>>> <xsd:complexType name="orderType">
>>> <xsd:sequence>
>>> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
>>> </xsd:sequence>
>>> </xsd:complexType>
>>> <!-- xsd snippet ends here -->
>>>
>>> //java code starts here
>>> XSDParticle particle = (XSDParticle)obj;
>>> XSDElementDeclaration element = (XSDElementDeclaration)
>>> particle.getContent();
>>>
>>> if(null != element.getTypeDefinition()) {
>>> XSDTypeDefinition typeDef = element.getTypeDefinition();
>>> XSDSimpleTypeDefinition simpleTypeDef = null;
>>>
>>> if(null != typeDef.getSimpleType()) {
>>> simpleTypeDef = typeDef.getSimpleType();
>>> // this is the question:
>>> //should I use this simpleTypeDef here???? or is there any
>>> simpler solution
>> Yes, you should use the simple type definition. They're the only
>> things with facets.
>>> }
>>> }
>>>
>>> Thanks.
>>> ~Nazir~
>>>
>>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Facets retrieving - getFacetContents [message #603251 is a reply to message #75399] Mon, 25 August 2008 23:52 Go to previous message
Muhamad Nazir is currently offline Muhamad NazirFriend
Messages: 24
Registered: July 2009
Junior Member
Ed,

In this case, even though I didn't specify any of my facets related to
this integer, getFacetContents will always get the defined facets in
XMLSchema.xsd? I bet other types too right?

Zillion thanks again,
~Nazir~

Ed Merks wrote:

> Nazir,

> Comments below.

> Muhamad Nazir Samsudin wrote:
>> Thanks for the quick response, Ed.
>>
>> Just another one, I noticed that when I was trying to get this using
>> simpleType:
>> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
>> it kinda gave me these facets:
>> fractionDigits='0', pattern='[-+]?[0-9]+'
>>
>> Any idea why I got these facets?
> Yes. The xsd:integer type is defined in the XMLSchema.xsd and it's
> definition there, along with the definitions of the rest of the type up
> its type hierarchy define these facets.
>> Thanks again.
>> ~Nazir~
>>
>> Ed Merks wrote:
>>
>>> Nazir,
>>
>>> Comments below.
>>
>>> Muhamad Nazir Samsudin wrote:
>>>> Hi Ed and all,
>>>>
>>>> I would like to know, what's the best way in retrieving facets. I
>>>> noticed a thread saying that we should use getFacetContents but
>>>> which one should I use in order to easily retrieve the facets,
>>>> faster and better. Is it using SimpleTypeDefinition or
>>>> TypeDefinition directly?
>>> It really comes down to what you want them for... More likely you
>>> want to use getFacets to get all the facets of all the type hierarchy
>>> merged nicely to give the ones that are applicable...
>>>>
>>>> I have something like this:
>>>> <!-- xsd snippet starts here -->
>>>> <xsd:complexType name="orderType">
>>>> <xsd:sequence>
>>>> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
>>>> </xsd:sequence>
>>>> </xsd:complexType>
>>>> <!-- xsd snippet ends here -->
>>>>
>>>> //java code starts here
>>>> XSDParticle particle = (XSDParticle)obj;
>>>> XSDElementDeclaration element = (XSDElementDeclaration)
>>>> particle.getContent();
>>>>
>>>> if(null != element.getTypeDefinition()) {
>>>> XSDTypeDefinition typeDef = element.getTypeDefinition();
>>>> XSDSimpleTypeDefinition simpleTypeDef = null;
>>>>
>>>> if(null != typeDef.getSimpleType()) {
>>>> simpleTypeDef = typeDef.getSimpleType();
>>>> // this is the question:
>>>> //should I use this simpleTypeDef here???? or is there any
>>>> simpler solution
>>> Yes, you should use the simple type definition. They're the only
>>> things with facets.
>>>> }
>>>> }
>>>>
>>>> Thanks.
>>>> ~Nazir~
>>>>
>>>>
>>
>>
Re: Facets retrieving - getFacetContents [message #603253 is a reply to message #75417] Tue, 26 August 2008 06:03 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Nazir,

The getFacets method returns the facets accumulated from the entire type
hierarchy including the part that's in the XMLSchema.xsd; these are the
facets that apply for any instance of that type. The getFacetContents
returns only the facets defined exactly on the specific type you're on.


Muhamad Nazir Samsudin wrote:
> Ed,
> In this case, even though I didn't specify any of my facets related to
> this integer, getFacetContents will always get the defined facets in
> XMLSchema.xsd? I bet other types too right?
>
> Zillion thanks again,
> ~Nazir~
>
> Ed Merks wrote:
>
>> Nazir,
>
>> Comments below.
>
>> Muhamad Nazir Samsudin wrote:
>>> Thanks for the quick response, Ed.
>>>
>>> Just another one, I noticed that when I was trying to get this using
>>> simpleType:
>>> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
>>> it kinda gave me these facets:
>>> fractionDigits='0', pattern='[-+]?[0-9]+'
>>>
>>> Any idea why I got these facets?
>> Yes. The xsd:integer type is defined in the XMLSchema.xsd and it's
>> definition there, along with the definitions of the rest of the type
>> up its type hierarchy define these facets.
>>> Thanks again.
>>> ~Nazir~
>>>
>>> Ed Merks wrote:
>>>
>>>> Nazir,
>>>
>>>> Comments below.
>>>
>>>> Muhamad Nazir Samsudin wrote:
>>>>> Hi Ed and all,
>>>>>
>>>>> I would like to know, what's the best way in retrieving facets. I
>>>>> noticed a thread saying that we should use getFacetContents but
>>>>> which one should I use in order to easily retrieve the facets,
>>>>> faster and better. Is it using SimpleTypeDefinition or
>>>>> TypeDefinition directly?
>>>> It really comes down to what you want them for... More likely you
>>>> want to use getFacets to get all the facets of all the type
>>>> hierarchy merged nicely to give the ones that are applicable...
>>>>>
>>>>> I have something like this:
>>>>> <!-- xsd snippet starts here -->
>>>>> <xsd:complexType name="orderType">
>>>>> <xsd:sequence>
>>>>> <xsd:element name="noOfOrder" minOccurs="0" type="xsd:integer"/>
>>>>> </xsd:sequence>
>>>>> </xsd:complexType>
>>>>> <!-- xsd snippet ends here -->
>>>>>
>>>>> //java code starts here
>>>>> XSDParticle particle = (XSDParticle)obj;
>>>>> XSDElementDeclaration element = (XSDElementDeclaration)
>>>>> particle.getContent();
>>>>>
>>>>> if(null != element.getTypeDefinition()) {
>>>>> XSDTypeDefinition typeDef = element.getTypeDefinition();
>>>>> XSDSimpleTypeDefinition simpleTypeDef = null;
>>>>>
>>>>> if(null != typeDef.getSimpleType()) {
>>>>> simpleTypeDef = typeDef.getSimpleType();
>>>>> // this is the question:
>>>>> //should I use this simpleTypeDef here???? or is there any
>>>>> simpler solution
>>>> Yes, you should use the simple type definition. They're the only
>>>> things with facets.
>>>>> }
>>>>> }
>>>>>
>>>>> Thanks.
>>>>> ~Nazir~
>>>>>
>>>>>
>>>
>>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Facets retrieving - getFacetContents
Next Topic:xsd schema import
Goto Forum:
  


Current Time: Fri Apr 19 00:11:06 GMT 2024

Powered by FUDForum. Page generated in 0.25043 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top