Thanks for the tip, Nikhil.
I've managed to create a tiny XSD Schema with this standalone code:
public void testEclipseXSD() {
//Create the root XSDSchema object
XSDSchema xsd = XSDFactory.eINSTANCE.createXSDSchema();
xsd.setTargetNamespace("myNS");
xsd.setSchemaForSchemaQNamePrefix("xsd");
java.util.Map qNamePrefixToNamespaceMap = xsd
.getQNamePrefixToNamespaceMap();
qNamePrefixToNamespaceMap.put(xsd.getSchemaForSchemaQNamePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
// add an element
XSDComplexTypeDefinition complexType = XSDFactory.eINSTANCE
.createXSDComplexTypeDefinition();
complexType.setName("myElement");
complexType.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL);
XSDSimpleTypeDefinition anonSimpleType = XSDFactory.eINSTANCE
.createXSDSimpleTypeDefinition();
complexType.setBaseTypeDefinition(xsd
.resolveSimpleTypeDefinition("myParent"));
complexType.setContent(anonSimpleType);
xsd.getContents().add(complexType);
xsd.updateElement();
dom = xsd.getDocument();
serialize(new OutputStreamWriter(System.out));
}
The result of which is this:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="whatever" xmlns:Q1="whatever"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="tst">
<xsd:simpleContent>
<xsd:extension base="Q1:parent"/>
</xsd:simpleContent>
</xsd:complexType>
</xsd:schema>
It's important to note that to get this to work you need to download a
complete archive from http://www.eclipse.org/xsd and put these jar
files in your classpath:
xsd_2.1.0.jar
emf.ecore_2.1.0.jar
emf.common_2.1.0.jar
which totals to about 1.5 Mb.
Running this function takes about 4 seconds in eclipse on a 2.6GHz machine.
Cheers, Jos
On 6/23/05, Nikhil Dinesh <[EMAIL PROTECTED]> wrote:
> Jos van den Oever wrote:
>
> >On Thursday 23 June 2005 18:38, Nikhil Dinesh wrote:
> >
> >
> >>You might want to check the eclipse xsd apidocs at:
> >>
> >>http://download.eclipse.org/tools/emf/xsd/2.1.0/javadoc/
> >>
> >>I "think" it gives you the functionality you want.
> >>-Nikhil
> >>
> >>
> >
> >
> >Hi Nikhil,
> >
> >That looks nice, but can you use it standalone?
> >I have trouble creating a Schema instance.
> >
> >Cheers, Jos
> >
> >
>
> Hi Jos,
>
> This, I'm not sure about having never used it. From past discussions on
> the group, it
> does seem possible (you might want to search for previous postings on
> eclipse xsd), and
> if memory serves there is considerable overlap between the xerces-j and
> eclipse xsd developers, so
> it might be best to wait until one of them responds...also Ive noticed
> that messages with eclipse xsd
> in the subject receive a flurry of responses, so you might consider
> reposting ;).
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]