|
Re: short question #2 how to obtain a XSDSchema from a String [message #41911 is a reply to message #41854] |
Tue, 20 April 2004 15:16 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
--------------77C1C8B8E7A20F6BBA0FEB50
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Joachim,
You again, so soon? ;-)
Assuming you do something much like what's in XSDMainTest in
org.eclipse.xsd.test, this should do the trick:
ResourceSet resourceSet = new ResourceSetImpl();
XSDResourceImpl xsdMainResource =
(XSDResourceImpl)resourceSet.createResource(URI.createURI("*.xsd "));
xsdMainResource.setURI(uri);
if (fromString)
{
xsdMainResource.load(/* ByteArrayInputStream created from
String */, resourceSet.getLoadOptions());
}
else
{
XSDSchema xsdSchema =
XSDPackage.eINSTANCE.createXSDSchema();
xsdSdchema.setElement(/* your <schema> element */);
xsdMainResource.getContents().add(xsdSchema);
}
An improved version of this would be FAQ worthy...
Joachim Lusiardi wrote:
> hello,
> it's me again ;-)
> How can i load a XSDSchema from a simple Java String?
> Or from a DOM Tree?
> greets
> Joachim Lusiardi
--------------77C1C8B8E7A20F6BBA0FEB50
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Joachim,
<p>You again, so soon? ;-)
<p>Assuming you do something much like what's in XSDMainTest in org.eclipse.xsd.test,
this should do the trick:
<blockquote>ResourceSet resourceSet = new ResourceSetImpl();
<br>XSDResourceImpl xsdMainResource = (XSDResourceImpl)resourceSet.createResource(URI.createURI("*.xsd "));
<br>xsdMainResource.setURI(uri);
<br>if (fromString)
<br>{
<br> xsdMainResource.load(/* ByteArrayInputStream created from String
*/, resourceSet.getLoadOptions());
<br>}
<br>else
<br>{
<br> XSDSchema xsdSchema = XSDPackage.eINSTANCE.createXSDSchema();
<br> xsdSdchema.setElement(/* your <schema> element */);
<br> xsdMainResource.getContents().add(xsdSchema);
<br>}</blockquote>
An improved version of this would be FAQ worthy...
<br>
<p>Joachim Lusiardi wrote:
<blockquote TYPE=CITE>hello,
<br>it's me again ;-)
<br>How can i load a XSDSchema from a simple Java String?
<br>Or from a DOM Tree?
<br>greets
<br>Joachim Lusiardi</blockquote>
</html>
--------------77C1C8B8E7A20F6BBA0FEB50--
|
|
|
Re: short question #2 how to obtain a XSDSchema from a String [message #585854 is a reply to message #41854] |
Tue, 20 April 2004 15:16 |
Ed Merks Messages: 33252 Registered: July 2009 |
Senior Member |
|
|
--------------77C1C8B8E7A20F6BBA0FEB50
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Joachim,
You again, so soon? ;-)
Assuming you do something much like what's in XSDMainTest in
org.eclipse.xsd.test, this should do the trick:
ResourceSet resourceSet = new ResourceSetImpl();
XSDResourceImpl xsdMainResource =
(XSDResourceImpl)resourceSet.createResource(URI.createURI("*.xsd "));
xsdMainResource.setURI(uri);
if (fromString)
{
xsdMainResource.load(/* ByteArrayInputStream created from
String */, resourceSet.getLoadOptions());
}
else
{
XSDSchema xsdSchema =
XSDPackage.eINSTANCE.createXSDSchema();
xsdSdchema.setElement(/* your <schema> element */);
xsdMainResource.getContents().add(xsdSchema);
}
An improved version of this would be FAQ worthy...
Joachim Lusiardi wrote:
> hello,
> it's me again ;-)
> How can i load a XSDSchema from a simple Java String?
> Or from a DOM Tree?
> greets
> Joachim Lusiardi
--------------77C1C8B8E7A20F6BBA0FEB50
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Joachim,
<p>You again, so soon? ;-)
<p>Assuming you do something much like what's in XSDMainTest in org.eclipse.xsd.test,
this should do the trick:
<blockquote>ResourceSet resourceSet = new ResourceSetImpl();
<br>XSDResourceImpl xsdMainResource = (XSDResourceImpl)resourceSet.createResource(URI.createURI("*.xsd "));
<br>xsdMainResource.setURI(uri);
<br>if (fromString)
<br>{
<br> xsdMainResource.load(/* ByteArrayInputStream created from String
*/, resourceSet.getLoadOptions());
<br>}
<br>else
<br>{
<br> XSDSchema xsdSchema = XSDPackage.eINSTANCE.createXSDSchema();
<br> xsdSdchema.setElement(/* your <schema> element */);
<br> xsdMainResource.getContents().add(xsdSchema);
<br>}</blockquote>
An improved version of this would be FAQ worthy...
<br>
<p>Joachim Lusiardi wrote:
<blockquote TYPE=CITE>hello,
<br>it's me again ;-)
<br>How can i load a XSDSchema from a simple Java String?
<br>Or from a DOM Tree?
<br>greets
<br>Joachim Lusiardi</blockquote>
</html>
--------------77C1C8B8E7A20F6BBA0FEB50--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03949 seconds