|
|
|
|
|
|
Re: org.eclipse.xsd.XSDSchema [message #898442 is a reply to message #898007] |
Thu, 26 July 2012 11:50 |
Slawek L Messages: 21 Registered: May 2012 |
Junior Member |
|
|
Thanks Ed for help, now it's more understandable, but still I have some questions...
for example:
<xs:complexType name="company">
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="name" type="xs:string"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="postCode" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
</xs:sequence>
</xs:complexType>
It is org.eclipse.xsd.XSDComplexTypeDefinition object, and how do I check how many tags are inside?
best regards
[Updated on: Thu, 26 July 2012 11:51] Report message to a moderator
|
|
|
|
|
|
|
Re: org.eclipse.xsd.XSDSchema [message #899677 is a reply to message #899577] |
Wed, 01 August 2012 18:41 |
Ed Merks Messages: 33264 Registered: July 2009 |
Senior Member |
|
|
Comments below.
On 01/08/2012 3:50 PM, Slawek L wrote:
> xsd file:
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xsd:schema xmlns:xsd="htp://www.w3.org/2001/XMLSchema">
> <xsd:annotation>
> <xsd:documentation>Description .</xsd:documentation>
> </xsd:annotation>
> <xsd:element name="application">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="applicant">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="father_name">
> <xsd:simpleType>
> <xsd:restriction base="xsd:string">
> <xsd:maxLength value="50"/>
> </xsd:restriction>
> </xsd:simpleType>
> </xsd:element>
> <xsd:element name="birthday">
> <xsd:simpleType>
> <xsd:restriction base="xsd:date"/>
> </xsd:simpleType>
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> <xsd:element name="date">
> <xsd:simpleType>
> <xsd:restriction base="xsd:date"/>
> </xsd:simpleType>
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
>
>
> Body of method
> String fileName = "c:\\ParserXSDExample\\b\\4.xsd";
> XSDSchema xsdSchema = null;
> XSDParser parser = null;
>
> try {
> parser = XSDParser.class.newInstance();
> parser.parse(fileName);
There's no example that shows to do this. The examples show how to use
a resource set. Why are you doing this? It doesn't build a schema so I
don't see how it produces output like what you show.
> xsdSchema = parser.getSchema();
> } catch (InstantiationException e) {
> e.printStackTrace();
> } catch (IllegalAccessException e) {
> e.printStackTrace();
> }
>
> int counter = 1;
> Document docu = xsdSchema.getDocument();
> TreeIterator<EObject> iterator = xsdSchema.eAllContents();
> while (iterator.hasNext()) {
> EObject object = (EObject) iterator.next();
> System.out.println(counter + "). element " +
> object.getClass());
>
> if (object instanceof XSDElementDeclaration) {
> XSDElementDeclaration xsdED=(XSDElementDeclaration)
> object;
> System.out.println(xsdED.getName());
> }
> counter++;
> }
>
> and it produces:
>
> application
> applicant
> father_name
> birthday
> date
>
> And it is OK, but expected output should looks like:
>
> application
> applicant
> father_name
> birthda
> applicant-Close
> date
> application-Close
>
> My problem is that I don't know how check that:
> -element applicant is inside other element(application)(applicant has
> a parent)
> -no more elements are inside applicant after birthda(birthday is last
> children)
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.05840 seconds