Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » short question #2 how to obtain a XSDSchema from a String
short question #2 how to obtain a XSDSchema from a String [message #41854] Tue, 20 April 2004 14:17 Go to next message
Joachim Lusiardi is currently offline Joachim LusiardiFriend
Messages: 18
Registered: July 2009
Junior Member
hello,
it's me again ;-)
How can i load a XSDSchema from a simple Java String?
Or from a DOM Tree?
greets
Joachim Lusiardi
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 Go to previous message
Eclipse UserFriend
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?&nbsp;&nbsp; ;-)
<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>&nbsp; xsdMainResource.load(/* ByteArrayInputStream created from String
*/, resourceSet.getLoadOptions());
<br>}
<br>else
<br>{
<br>&nbsp; XSDSchema xsdSchema = XSDPackage.eINSTANCE.createXSDSchema();
<br>&nbsp; xsdSdchema.setElement(/* your &lt;schema> element */);
<br>&nbsp; xsdMainResource.getContents().add(xsdSchema);
<br>}</blockquote>
An improved version of this would be FAQ worthy...
<br>&nbsp;
<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 Go to previous message
Ed Merks is currently offline Ed MerksFriend
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?&nbsp;&nbsp; ;-)
<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>&nbsp; xsdMainResource.load(/* ByteArrayInputStream created from String
*/, resourceSet.getLoadOptions());
<br>}
<br>else
<br>{
<br>&nbsp; XSDSchema xsdSchema = XSDPackage.eINSTANCE.createXSDSchema();
<br>&nbsp; xsdSdchema.setElement(/* your &lt;schema> element */);
<br>&nbsp; xsdMainResource.getContents().add(xsdSchema);
<br>}</blockquote>
An improved version of this would be FAQ worthy...
<br>&nbsp;
<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/
Previous Topic:short question #2 how to obtain a XSDSchema from a String
Next Topic:Processing complexTypes derived by extension
Goto Forum:
  


Current Time: Sat Nov 09 01:00:18 GMT 2024

Powered by FUDForum. Page generated in 0.03949 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top