Hallo,

hat schon mal jemand mit xsom (http://xsom.java.net/) gearbeitet?

beispielsweise habe ich folgenden komplexen Typ:

Code :
1
2
3
4
5
6
<complexType name="BoundingShapeType">
        <sequence>
            <element ref="Envelope"/>
        </sequence>
        <attribute name="nilReason" type="NilReasonType"/>
    </complexType>

und nun möchte ich mit dem XSOM-Parser durch Abfrage dieses Typs wissen, ob bspw. eine Elementreferenz vorliegt.

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import com.sun.xml.xsom.*;
import java.io.File;
import com.sun.xml.xsom.parser.XSOMParser;
import com.sun.xml.xsom.XSSchemaSet;
 
public class XSDParser {
    public static void main(String args[]){
        XSSchema xsSchema;
        
        try{
            XSOMParser parser = new XSOMParser();
            parser.parse(new File("test.xsd"));
 
            XSSchemaSet schemaSet = parser.getResult();
            xsSchema = schemaSet.getSchema(1);
        }catch (Exception exp) {
            exp.printStackTrace(System.out);
        }
            
        XSComplexType ct = (ComplexType) xsSchema.getComplexType("BoundingShapeType");
        XSContentType contentType = ct.getContentType();
        XSParticle particle = contentType.asParticle();
        if(particle != null){
           XSTerm term = particle.getTerm();
           if(term.isElementDecl()){
              XSElementDecl elem = term.asXSElementDecl();
              //jetzt bspw. prüfen ob eine Referenz vorliegt
           }
        }
     
     }
}

Kann mir da jemand helfen?

gruß jazzhunter