atom feed5 messages in net.java.dev.xsom.usersRe: Children from XSElementDecl
FromSent OnAttachments
Vincent HerrmannDec 1, 2009 7:36 am 
Chaubal, MayureshDec 2, 2009 2:25 am 
Vincent HerrmannDec 2, 2009 5:19 am 
Chaubal, MayureshDec 4, 2009 4:19 am 
Vincent HerrmannDec 7, 2009 8:21 am 
Subject:Re: Children from XSElementDecl
From:Vincent Herrmann (vinc@free.fr)
Date:Dec 7, 2009 8:21:34 am
List:net.java.dev.xsom.users

Hello,

I tried various things and I understood how work xsom. It's works perfectly now, thank you for your help!

Regards, Vincent

Le 4 déc. 09 à 13:20, Chaubal, Mayuresh a écrit :

Use of XSVisitor is on similar basis of sax parsing in java. Respective method is called when event occurs.

Although internal plumbing has to be done by us.

Pls refer the sample implementation below

package xsdparser.visitors;

import com.sun.xml.xsom.XSAnnotation; import com.sun.xml.xsom.XSAttGroupDecl; import com.sun.xml.xsom.XSAttributeDecl; import com.sun.xml.xsom.XSAttributeUse; import com.sun.xml.xsom.XSComplexType; import com.sun.xml.xsom.XSContentType; import com.sun.xml.xsom.XSElementDecl; import com.sun.xml.xsom.XSFacet; import com.sun.xml.xsom.XSIdentityConstraint; import com.sun.xml.xsom.XSModelGroup; import com.sun.xml.xsom.XSModelGroupDecl; import com.sun.xml.xsom.XSNotation; import com.sun.xml.xsom.XSParticle; import com.sun.xml.xsom.XSSchema; import com.sun.xml.xsom.XSSimpleType; import com.sun.xml.xsom.XSWildcard; import com.sun.xml.xsom.XSXPath; import com.sun.xml.xsom.visitor.XSVisitor;

public class TestVisitor implements XSVisitor{

public void annotation(XSAnnotation arg0) { System.out.println("annotation : " + arg0.getAnnotation());

}

public void attGroupDecl(XSAttGroupDecl arg0) { System.out.println("attGroupDecl : " + arg0.getAnnotation());

}

public void attributeDecl(XSAttributeDecl arg0) { System.out.println("attributeDecl : " + arg0.getAnnotation());

}

public void attributeUse(XSAttributeUse arg0) { System.out.println("attributeUse : " + arg0.getAnnotation());

}

public void complexType(XSComplexType arg0) { System.out.println("complexType : " + arg0.getAnnotation());

}

public void facet(XSFacet arg0) { System.out.println("facet : " + arg0.getAnnotation());

}

public void identityConstraint(XSIdentityConstraint arg0) { System.out.println("identityConstraint : " + arg0.getAnnotation());

}

public void notation(XSNotation arg0) { System.out.println("notation : " + arg0.getAnnotation());

}

public void schema(XSSchema arg0) { System.out.println("schema : " + arg0.getAnnotation());

}

public void xpath(XSXPath arg0) { System.out.println("xpath : " + arg0.getAnnotation());

}

public void elementDecl(XSElementDecl arg0) { System.out.println("elementDecl : " + arg0.getAnnotation());

}

public void modelGroup(XSModelGroup arg0) { System.out.println("modelGroup : " + arg0.getAnnotation());

}

public void modelGroupDecl(XSModelGroupDecl arg0) { System.out.println("modelGroupDecl : " + arg0.getAnnotation());

}

public void wildcard(XSWildcard arg0) { System.out.println("wildcard : " + arg0.getAnnotation());

}

public void empty(XSContentType arg0) { System.out.println("empty : " + arg0.getAnnotation());

}

public void particle(XSParticle arg0) { System.out.println("particle : " + arg0.getTerm());

}

public void simpleType(XSSimpleType arg0) { System.out.println("simpletype : " + arg0.getName());

}

}

Regards, Mayuresh

From: Vincent Herrmann [mailto:vinc@free.fr] Sent: Wednesday, December 02, 2009 6:50 PM To: use@xsom.dev.java.net Subject: Re: Children from XSElementDecl

HI,

thank you for your reply.

I'm not using XSVisitor.

Actually I use this code for set all markers in a list :

try { XSOMParser parser = new XSOMParser(); parser.parse(xsdFile); XSSchemaSet result = parser.getResult(); Iterator<XSSchema> it = result.iterateSchema(); ArrayList<XSElementDecl> tempListMarker = new ArrayList<XSElementDecl>(); Iterator<XSElementDecl> iterator = result.iterateElementDecls(); while(iterator.hasNext()) tempListMarker.add(iterator.next());

listMarkers = tempListMarker.toArray(new XSElementDecl[tempListMarker.size()]); } catch (SAXException e) {e.printStackTrace(); } catch (IOException e) {e.printStackTrace();}

The user choose a XSElementDecl and my soft create a new XML fil with the user's XSElementDecl as root element. After I try to print all XSElementDecl possible after this root element.

Now I try to use XSVisitor implementation, but I didn't understand the utility of XSVisitor and I don't know how to use it. Have you an example of XSVisitor implementation please?

Thank you again and excuse me for my poor english.

Regards, Vincent

Le 2 déc. 09 à 11:25, Chaubal, Mayuresh a écrit :

Are you using XSVisitor implementation?

It becomes easy when we put our business code in an implementation of XSVisitor. I hope the following code will help.

Iterator<XSSchema> schemas = set.iterateSchema();

while(schemas.hasNext()){ XSSchema current = schemas.next(); current.visit(visitor); }

Here visitor is implementation of XSVisitor.

Regards, Mayuresh

-----Original Message----- From: Vincent Herrmann [mailto:vinc@free.fr] Sent: Tuesday, December 01, 2009 9:07 PM To: use@xsom.dev.java.net Subject: Children from XSElementDecl

Hi,

I try to parse a XML Schema but I have a problem.

I need to know all possible Marker in the XML file after a Maker. How to know the Marker's children?

I can list all markers in the schema in using iterateElementDecls on a XSSchemSet. But when I have a XSElementDecl I don't know how to have acces to is children.