Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » how to find the element that is refered using ref attribute.
how to find the element that is refered using ref attribute. [message #35560] Tue, 13 January 2004 07:36 Go to next message
Eclipse UserFriend
Originally posted by: mmahesh.firstam.com

in the following XSD how to get the element that are refered in the
REQUEST_GROUP in the complex type element as ref.


<xsd:element name="REQUEST_GROUP">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="REQUESTING_PARTY" minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element ref="RECEIVING_PARTY" minOccurs="0"/>
<xsd:element ref="SUBMITTING_PARTY" minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element ref="REQUEST" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="MISMOVersionID" type="xsd:string" fixed="2.3"/>
<xsd:attribute name="BundleProductIdentifier_Extension"
type="xsd:string" use="optional"/>
</xsd:complexType>
</xsd:element>

<xsd:element name="REQUEST">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="KEY" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="REQUEST_DATA" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="RequestDatetime" type="xsd:string" use="optional"/>
<xsd:attribute name="InternalAccountIdentifier" type="xsd:string"
use="optional"/>
<xsd:attribute name="LoginAccountIdentifier" type="xsd:string"
use="optional"/>
<xsd:attribute name="LoginAccountPassword" type="xsd:string"
use="optional"/>
<xsd:attribute name="RequestingPartyBranchIdentifier" type="xsd:string"
use="optional"/>
</xsd:complexType>
</xsd:element>
Re: how to find the element that is refered using ref attribute. [message #35627 is a reply to message #35560] Tue, 13 January 2004 13:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: crscca.bol.net.in

I use the following techniques shown in some of my code. It should solve
your problem I think.


boolean isRef = elementDec.isElementDeclarationReference();


private static XSDElementDeclaration
resolveElementDeclaration(XSDElementDeclaration elementDec)
{
if (elementDec.isElementDeclarationReference())
{
elementDec = elementDec.getResolvedElementDeclaration();
if (elementDec.isElementDeclarationReference())
elementDec = resolveElementDeclaration(elementDec);
}
return elementDec;
}

Raster




mahesh wrote:

> in the following XSD how to get the element that are refered in the
> REQUEST_GROUP in the complex type element as ref.


> <xsd:element name="REQUEST_GROUP">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element ref="REQUESTING_PARTY" minOccurs="0"
> maxOccurs="unbounded"/>
> <xsd:element ref="RECEIVING_PARTY" minOccurs="0"/>
> <xsd:element ref="SUBMITTING_PARTY" minOccurs="0"
> maxOccurs="unbounded"/>
> <xsd:element ref="REQUEST" minOccurs="0" maxOccurs="unbounded"/>
> </xsd:sequence>
> <xsd:attribute name="MISMOVersionID" type="xsd:string" fixed="2.3"/>
> <xsd:attribute name="BundleProductIdentifier_Extension"
> type="xsd:string" use="optional"/>
> </xsd:complexType>
> </xsd:element>

> <xsd:element name="REQUEST">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element ref="KEY" minOccurs="0" maxOccurs="unbounded"/>
> <xsd:element ref="REQUEST_DATA" minOccurs="0" maxOccurs="unbounded"/>
> </xsd:sequence>
> <xsd:attribute name="RequestDatetime" type="xsd:string" use="optional"/>
> <xsd:attribute name="InternalAccountIdentifier" type="xsd:string"
> use="optional"/>
> <xsd:attribute name="LoginAccountIdentifier" type="xsd:string"
> use="optional"/>
> <xsd:attribute name="LoginAccountPassword" type="xsd:string"
> use="optional"/>
> <xsd:attribute name="RequestingPartyBranchIdentifier" type="xsd:string"
> use="optional"/>
> </xsd:complexType>
> </xsd:element>
Re: how to find the element that is refered using ref attribute. [message #35830 is a reply to message #35627] Wed, 14 January 2004 14:30 Go to previous messageGo to next message
David Steinberg is currently offline David SteinbergFriend
Messages: 489
Registered: July 2009
Senior Member
Raster wrote:

> private static XSDElementDeclaration
> resolveElementDeclaration(XSDElementDeclaration elementDec)
> {
> if (elementDec.isElementDeclarationReference())
> {
> elementDec = elementDec.getResolvedElementDeclaration();
> if (elementDec.isElementDeclarationReference())
> elementDec = resolveElementDeclaration(elementDec);
> }
> return elementDec;
> }

Hi Raster,

If an XSDElementDeclaration represents a real declaration, and not a
reference (i.e. if isElementDeclarationReference() is false), then
getReslvedElementDeclaration() will simply return the object itself.
Moreover, the object returned by getResolvedElementDeclaration() always
represents a real declaration (i.e. isElementDeclarationReference() is
false). So, any use of this resolveElementDeclaration(elementDec) method
could simply be replaced by elementDec.getResolvedElementDeclaration().

Also, note that XSDAttributeDeclaration.getResolvedAttributeDeclaration(),
XSDAttributeGroupDefinition.getResolvedAttributeGroupDefinit ion, and
XSDModelGroupDefinition.getResolvedModelGroupDefinition() work the same way.

Cheers,
Dave
Re: how to find the element that is refered using ref attribute. [message #35929 is a reply to message #35830] Thu, 15 January 2004 13:25 Go to previous message
Eclipse UserFriend
Originally posted by: crscca.bol.net.in

I thought so myself but was playing safe hence the recursive method. In
any case I was sure you would react if I was wrong which you did. Thanks
for correcting me.

Thanks.

Dave Steinberg wrote:

> Raster wrote:

> > private static XSDElementDeclaration
> > resolveElementDeclaration(XSDElementDeclaration elementDec)
> > {
> > if (elementDec.isElementDeclarationReference())
> > {
> > elementDec = elementDec.getResolvedElementDeclaration();
> > if (elementDec.isElementDeclarationReference())
> > elementDec = resolveElementDeclaration(elementDec);
> > }
> > return elementDec;
> > }

> Hi Raster,

> If an XSDElementDeclaration represents a real declaration, and not a
> reference (i.e. if isElementDeclarationReference() is false), then
> getReslvedElementDeclaration() will simply return the object itself.
> Moreover, the object returned by getResolvedElementDeclaration() always
> represents a real declaration (i.e. isElementDeclarationReference() is
> false). So, any use of this resolveElementDeclaration(elementDec) method
> could simply be replaced by elementDec.getResolvedElementDeclaration().

> Also, note that XSDAttributeDeclaration.getResolvedAttributeDeclaration(),
> XSDAttributeGroupDefinition.getResolvedAttributeGroupDefinit ion, and
> XSDModelGroupDefinition.getResolvedModelGroupDefinition() work the same way.

> Cheers,
> Dave
Re: how to find the element that is refered using ref attribute. [message #582603 is a reply to message #35560] Tue, 13 January 2004 13:24 Go to previous message
Raster R is currently offline Raster RFriend
Messages: 77
Registered: July 2009
Member
I use the following techniques shown in some of my code. It should solve
your problem I think.


boolean isRef = elementDec.isElementDeclarationReference();


private static XSDElementDeclaration
resolveElementDeclaration(XSDElementDeclaration elementDec)
{
if (elementDec.isElementDeclarationReference())
{
elementDec = elementDec.getResolvedElementDeclaration();
if (elementDec.isElementDeclarationReference())
elementDec = resolveElementDeclaration(elementDec);
}
return elementDec;
}

Raster




mahesh wrote:

> in the following XSD how to get the element that are refered in the
> REQUEST_GROUP in the complex type element as ref.


> <xsd:element name="REQUEST_GROUP">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element ref="REQUESTING_PARTY" minOccurs="0"
> maxOccurs="unbounded"/>
> <xsd:element ref="RECEIVING_PARTY" minOccurs="0"/>
> <xsd:element ref="SUBMITTING_PARTY" minOccurs="0"
> maxOccurs="unbounded"/>
> <xsd:element ref="REQUEST" minOccurs="0" maxOccurs="unbounded"/>
> </xsd:sequence>
> <xsd:attribute name="MISMOVersionID" type="xsd:string" fixed="2.3"/>
> <xsd:attribute name="BundleProductIdentifier_Extension"
> type="xsd:string" use="optional"/>
> </xsd:complexType>
> </xsd:element>

> <xsd:element name="REQUEST">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element ref="KEY" minOccurs="0" maxOccurs="unbounded"/>
> <xsd:element ref="REQUEST_DATA" minOccurs="0" maxOccurs="unbounded"/>
> </xsd:sequence>
> <xsd:attribute name="RequestDatetime" type="xsd:string" use="optional"/>
> <xsd:attribute name="InternalAccountIdentifier" type="xsd:string"
> use="optional"/>
> <xsd:attribute name="LoginAccountIdentifier" type="xsd:string"
> use="optional"/>
> <xsd:attribute name="LoginAccountPassword" type="xsd:string"
> use="optional"/>
> <xsd:attribute name="RequestingPartyBranchIdentifier" type="xsd:string"
> use="optional"/>
> </xsd:complexType>
> </xsd:element>
Re: how to find the element that is refered using ref attribute. [message #582717 is a reply to message #35627] Wed, 14 January 2004 14:30 Go to previous message
David Steinberg is currently offline David SteinbergFriend
Messages: 489
Registered: July 2009
Senior Member
Raster wrote:

> private static XSDElementDeclaration
> resolveElementDeclaration(XSDElementDeclaration elementDec)
> {
> if (elementDec.isElementDeclarationReference())
> {
> elementDec = elementDec.getResolvedElementDeclaration();
> if (elementDec.isElementDeclarationReference())
> elementDec = resolveElementDeclaration(elementDec);
> }
> return elementDec;
> }

Hi Raster,

If an XSDElementDeclaration represents a real declaration, and not a
reference (i.e. if isElementDeclarationReference() is false), then
getReslvedElementDeclaration() will simply return the object itself.
Moreover, the object returned by getResolvedElementDeclaration() always
represents a real declaration (i.e. isElementDeclarationReference() is
false). So, any use of this resolveElementDeclaration(elementDec) method
could simply be replaced by elementDec.getResolvedElementDeclaration().

Also, note that XSDAttributeDeclaration.getResolvedAttributeDeclaration(),
XSDAttributeGroupDefinition.getResolvedAttributeGroupDefinit ion, and
XSDModelGroupDefinition.getResolvedModelGroupDefinition() work the same way.

Cheers,
Dave
Re: how to find the element that is refered using ref attribute. [message #582760 is a reply to message #35830] Thu, 15 January 2004 13:25 Go to previous message
Raster R is currently offline Raster RFriend
Messages: 77
Registered: July 2009
Member
I thought so myself but was playing safe hence the recursive method. In
any case I was sure you would react if I was wrong which you did. Thanks
for correcting me.

Thanks.

Dave Steinberg wrote:

> Raster wrote:

> > private static XSDElementDeclaration
> > resolveElementDeclaration(XSDElementDeclaration elementDec)
> > {
> > if (elementDec.isElementDeclarationReference())
> > {
> > elementDec = elementDec.getResolvedElementDeclaration();
> > if (elementDec.isElementDeclarationReference())
> > elementDec = resolveElementDeclaration(elementDec);
> > }
> > return elementDec;
> > }

> Hi Raster,

> If an XSDElementDeclaration represents a real declaration, and not a
> reference (i.e. if isElementDeclarationReference() is false), then
> getReslvedElementDeclaration() will simply return the object itself.
> Moreover, the object returned by getResolvedElementDeclaration() always
> represents a real declaration (i.e. isElementDeclarationReference() is
> false). So, any use of this resolveElementDeclaration(elementDec) method
> could simply be replaced by elementDec.getResolvedElementDeclaration().

> Also, note that XSDAttributeDeclaration.getResolvedAttributeDeclaration(),
> XSDAttributeGroupDefinition.getResolvedAttributeGroupDefinit ion, and
> XSDModelGroupDefinition.getResolvedModelGroupDefinition() work the same way.

> Cheers,
> Dave
Previous Topic:use="required"/use="optional"
Next Topic:Search for Element Declaration
Goto Forum:
  


Current Time: Fri Apr 26 02:36:26 GMT 2024

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

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

Back to the top