finding elements or attributes based on Types [message #36367] |
Wed, 21 January 2004 16:16 |
Eclipse User |
|
|
|
Originally posted by: niemaz.xrce.xerox.com
Hi,
I'm trying to find out how to retrieve every elements or attributes that
are based on a global simpleTypeDefinition. I've tried with
findElementsUsingType but with no luck ;-(
For exemple, I'd like something that'd tell me that the simpleType
'atacharacType' is used in 'titi' (and others ...). 'titi' being an
attribute or an element.
<xs:simpleType name="atacharacType">
<xs:restriction base="xs:string">
<xs:pattern value="\d\d(-\d\d(-\d\d)?)?"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="ata">
<xs:complexType>
<xs:sequence>
<xs:element name="titi" type="atacharacType" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>bla bla bla</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
thanx,
--mike
|
|
|
Re: finding elements or attributes based on Types [message #36417 is a reply to message #36367] |
Wed, 21 January 2004 20:36 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
--------------7B4B71396F9902438712601F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Mike,
The findElementsUsingType method only searches global element declarations but
in your example it's a local element declaration you want to find. There are
many ways to tackle this problem. This simple brute force approach will do
the trick for a given schema component:
for (Iterator i = xsdSchema.eAllContents(); i.hasNext(); )
{
Object o = i.next();
if (o instanceof XSDFeature)
{
XSDFeature xsdFeature = (XSDFeature)o;
if (xsdFeature.getType() == whatever)
{
// We have a matching element or attribute declaration.
}
}
}
It walks the schema containment tree looking for features (i.e., elements or
attributes) with a type that matches a specific type...
mike wrote:
> Hi,
> I'm trying to find out how to retrieve every elements or attributes that
> are based on a global simpleTypeDefinition. I've tried with
> findElementsUsingType but with no luck ;-(
> For exemple, I'd like something that'd tell me that the simpleType
> 'atacharacType' is used in 'titi' (and others ...). 'titi' being an
> attribute or an element.
>
> <xs:simpleType name="atacharacType">
> <xs:restriction base="xs:string">
> <xs:pattern value="\d\d(-\d\d(-\d\d)?)?"/>
> </xs:restriction>
> </xs:simpleType>
>
> <xs:element name="ata">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="titi" type="atacharacType" maxOccurs="unbounded">
> <xs:annotation>
> <xs:documentation>bla bla bla</xs:documentation>
> </xs:annotation>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> thanx,
>
> --mike
--------------7B4B71396F9902438712601F
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Mike,
<p>The findElementsUsingType method only searches global element declarations
but in your example it's a local element declaration you want to find.
There are many ways to tackle this problem. This simple brute force
approach will do the trick for a given schema component:
<blockquote>for (Iterator i = xsdSchema.eAllContents(); i.hasNext(); )
<br>{
<br> Object o = i.next();
<br> if (o instanceof XSDFeature)
<br> {
<br> XSDFeature xsdFeature = (XSDFeature)o;
<br> if (xsdFeature.getType() == whatever)
<br> {
<br> // We have a matching element or attribute
declaration.
<br> }
<br> }
<br>}</blockquote>
It walks the schema containment tree looking for features (i.e., elements
or attributes) with a type that matches a specific type...
<br>
<p>mike wrote:
<blockquote TYPE=CITE>Hi,
<br> I'm trying to find out how to retrieve every elements or attributes
that
<br>are based on a global simpleTypeDefinition. I've tried with
<br>findElementsUsingType but with no luck ;-(
<br>For exemple, I'd like something that'd tell me that the simpleType
<br>'atacharacType' is used in 'titi' (and others ...). 'titi' being an
<br>attribute or an element.
<p><xs:simpleType name="atacharacType">
<br> <xs:restriction base="xs:string">
<br> <xs:pattern value="\d\d(-\d\d(-\d\d)?)?"/>
<br> </xs:restriction>
<br></xs:simpleType>
<p><xs:element name="ata">
<br> <xs:complexType>
<br> <xs:sequence>
<br> <xs:element name="titi" type="atacharacType" maxOccurs="unbounded">
<br> <xs:annotation>
<br> <xs:documentation>bla bla bla</xs:documentation>
<br> </xs:annotation>
<br> </xs:element>
<br> </xs:sequence>
<br> </xs:complexType>
<br></xs:element>
<p>thanx,
<p>--mike</blockquote>
</html>
--------------7B4B71396F9902438712601F--
|
|
|
Re: finding elements or attributes based on Types [message #36497 is a reply to message #36417] |
Thu, 22 January 2004 11:58 |
Eclipse User |
|
|
|
Originally posted by: niemaz.xrce.xerox.com
Thanx a lot,
--mike
nb: If the root schema is provided, would it look for elements inside
included schemas?
Ed Merks wrote:
> Mike,
> The findElementsUsingType method only searches global element declarations
but
> in your example it's a local element declaration you want to find. There are
> many ways to tackle this problem. This simple brute force approach will do
> the trick for a given schema component:
> for (Iterator i = xsdSchema.eAllContents(); i.hasNext(); )
> {
> Object o = i.next();
> if (o instanceof XSDFeature)
> {
> XSDFeature xsdFeature = (XSDFeature)o;
> if (xsdFeature.getType() == whatever)
> {
> // We have a matching element or attribute declaration.
> }
> }
> }
> It walks the schema containment tree looking for features (i.e., elements or
> attributes) with a type that matches a specific type...
> mike wrote:
> > Hi,
> > I'm trying to find out how to retrieve every elements or attributes that
> > are based on a global simpleTypeDefinition. I've tried with
> > findElementsUsingType but with no luck ;-(
> > For exemple, I'd like something that'd tell me that the simpleType
> > 'atacharacType' is used in 'titi' (and others ...). 'titi' being an
> > attribute or an element.
> >
> > <xs:simpleType name="atacharacType">
> > <xs:restriction base="xs:string">
> > <xs:pattern value="dd(-dd(-dd)?)?"/>
> > </xs:restriction>
> > </xs:simpleType>
> >
> > <xs:element name="ata">
> > <xs:complexType>
> > <xs:sequence>
> > <xs:element name="titi" type="atacharacType" maxOccurs="unbounded">
> > <xs:annotation>
> > <xs:documentation>bla bla bla</xs:documentation>
> > </xs:annotation>
> > </xs:element>
> > </xs:sequence>
> > </xs:complexType>
> > </xs:element>
> >
> > thanx,
> >
> > --mike
|
|
|
Re: finding elements or attributes based on Types [message #583057 is a reply to message #36367] |
Wed, 21 January 2004 20:36 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
--------------7B4B71396F9902438712601F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Mike,
The findElementsUsingType method only searches global element declarations but
in your example it's a local element declaration you want to find. There are
many ways to tackle this problem. This simple brute force approach will do
the trick for a given schema component:
for (Iterator i = xsdSchema.eAllContents(); i.hasNext(); )
{
Object o = i.next();
if (o instanceof XSDFeature)
{
XSDFeature xsdFeature = (XSDFeature)o;
if (xsdFeature.getType() == whatever)
{
// We have a matching element or attribute declaration.
}
}
}
It walks the schema containment tree looking for features (i.e., elements or
attributes) with a type that matches a specific type...
mike wrote:
> Hi,
> I'm trying to find out how to retrieve every elements or attributes that
> are based on a global simpleTypeDefinition. I've tried with
> findElementsUsingType but with no luck ;-(
> For exemple, I'd like something that'd tell me that the simpleType
> 'atacharacType' is used in 'titi' (and others ...). 'titi' being an
> attribute or an element.
>
> <xs:simpleType name="atacharacType">
> <xs:restriction base="xs:string">
> <xs:pattern value="\d\d(-\d\d(-\d\d)?)?"/>
> </xs:restriction>
> </xs:simpleType>
>
> <xs:element name="ata">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="titi" type="atacharacType" maxOccurs="unbounded">
> <xs:annotation>
> <xs:documentation>bla bla bla</xs:documentation>
> </xs:annotation>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> thanx,
>
> --mike
--------------7B4B71396F9902438712601F
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Mike,
<p>The findElementsUsingType method only searches global element declarations
but in your example it's a local element declaration you want to find.
There are many ways to tackle this problem. This simple brute force
approach will do the trick for a given schema component:
<blockquote>for (Iterator i = xsdSchema.eAllContents(); i.hasNext(); )
<br>{
<br> Object o = i.next();
<br> if (o instanceof XSDFeature)
<br> {
<br> XSDFeature xsdFeature = (XSDFeature)o;
<br> if (xsdFeature.getType() == whatever)
<br> {
<br> // We have a matching element or attribute
declaration.
<br> }
<br> }
<br>}</blockquote>
It walks the schema containment tree looking for features (i.e., elements
or attributes) with a type that matches a specific type...
<br>
<p>mike wrote:
<blockquote TYPE=CITE>Hi,
<br> I'm trying to find out how to retrieve every elements or attributes
that
<br>are based on a global simpleTypeDefinition. I've tried with
<br>findElementsUsingType but with no luck ;-(
<br>For exemple, I'd like something that'd tell me that the simpleType
<br>'atacharacType' is used in 'titi' (and others ...). 'titi' being an
<br>attribute or an element.
<p><xs:simpleType name="atacharacType">
<br> <xs:restriction base="xs:string">
<br> <xs:pattern value="\d\d(-\d\d(-\d\d)?)?"/>
<br> </xs:restriction>
<br></xs:simpleType>
<p><xs:element name="ata">
<br> <xs:complexType>
<br> <xs:sequence>
<br> <xs:element name="titi" type="atacharacType" maxOccurs="unbounded">
<br> <xs:annotation>
<br> <xs:documentation>bla bla bla</xs:documentation>
<br> </xs:annotation>
<br> </xs:element>
<br> </xs:sequence>
<br> </xs:complexType>
<br></xs:element>
<p>thanx,
<p>--mike</blockquote>
</html>
--------------7B4B71396F9902438712601F--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03665 seconds