Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Load XML Schema from File and extract Types
Load XML Schema from File and extract Types [message #66124] Sun, 19 February 2006 11:35 Go to next message
Eclipse User
Originally posted by: marcopk84.yahoo.it

Hello to all !
it is the first time that I write here......

I am developing a EditorXml that it allows to validate an XML file xml
based on the XML Schema contained in a file .xsd !

I'm interested for being able to give some suggestions during the writing
, I need to load the names of the SympleTag ComplexTag declared in .xsd
file .

For Example .... if I have an xsd file like this ...

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:simpleType name="stringtype">
<xs:restriction base="xs:string"/>
</xs:simpleType>

<xs:simpleType name="inttype">
<xs:restriction base="xs:positiveInteger"/>
</xs:simpleType>

<xs:complexType name="shiptotype">
<xs:sequence>
<xs:element name="name" type="stringtype"/>
<xs:element name="address" type="inttype"/>
<xs:element name="city" type="stringtype"/>
<xs:element name="country" type="stringtype"/>
</xs:sequence>
</xs:complexType>

</xs:schema>

I'm interested to get for example "shiptotype" "name" "address" "city"
"country" ...... but no "stringtype" or "xs:positiveInteger"

I hope you can help me with suggestion or JavaCode ....

Sorry for my English ...
Re: Load XML Schema from File and extract Types [message #66145 is a reply to message #66124] Mon, 20 February 2006 13:04 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

Load the schema as illustrated in XSDMainExample and use
XSDSchema.getTypeDefinitions to get the list of all types. You'll need
to walk the complex type's complex content (a tree of XSDParticles) to
visit the elements of shiptotype.

marcopk wrote:

> Hello to all !
> it is the first time that I write here......
> I am developing a EditorXml that it allows to validate an XML file xml
> based on the XML Schema contained in a file .xsd !
>
> I'm interested for being able to give some suggestions during the
> writing , I need to load the names of the SympleTag ComplexTag
> declared in .xsd file .
>
> For Example .... if I have an xsd file like this ...
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <xs:simpleType name="stringtype">
> <xs:restriction base="xs:string"/>
> </xs:simpleType>
>
> <xs:simpleType name="inttype">
> <xs:restriction base="xs:positiveInteger"/>
> </xs:simpleType>
>
> <xs:complexType name="shiptotype">
> <xs:sequence>
> <xs:element name="name" type="stringtype"/>
> <xs:element name="address" type="inttype"/>
> <xs:element name="city" type="stringtype"/>
> <xs:element name="country" type="stringtype"/>
> </xs:sequence>
> </xs:complexType>
>
> </xs:schema>
>
> I'm interested to get for example "shiptotype" "name" "address" "city"
> "country" ...... but no "stringtype" or "xs:positiveInteger"
>
> I hope you can help me with suggestion or JavaCode ....
>
> Sorry for my English ...
>
Re: Load XML Schema from File and extract Types [message #66166 is a reply to message #66145] Mon, 20 February 2006 14:49 Go to previous messageGo to next message
Eclipse User
Originally posted by: marcopk84.yahoo.it

Thanks for the Answer ...

But I have one problem at lines ...

XSDResourceImpl xsdMainResource =
(XSDResourceImpl)resourceSet.createResource(URI.createURI("File.xsd "));
xsdMainResource.setURI(uri);

give me "java.lang.NullPointerException" ....

Can you help me ?

Thanks

Marco
Re: Load XML Schema from File and extract Types [message #66186 is a reply to message #66166] Mon, 20 February 2006 16:55 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------050307030808010402060708
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Marco,

It sounds like you haven't registered a resource factory to handle files
with "xsd" extension (as shown in the example):

resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xsd",
new XSDResourceFactoryImpl());

Are you trying to load a resource or create an empty new one?


marcopk wrote:

> Thanks for the Answer ...
> But I have one problem at lines ...
>
> XSDResourceImpl xsdMainResource =
> (XSDResourceImpl)resourceSet.createResource(URI.createURI("File.xsd "));
> xsdMainResource.setURI(uri);
>
> give me "java.lang.NullPointerException" ....
>
> Can you help me ?
> Thanks
> Marco
>
>


--------------050307030808010402060708
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Marco,<br>
<br>
It sounds like you haven't registered a resource factory to handle
files with "xsd" extension (as shown in the example):<br>
<blockquote> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xsd",
new XSDResourceFactoryImpl());<br>
</blockquote>
Are you trying to load a resource or create an empty new one?<br>
<br>
<br>
marcopk wrote:
<blockquote cite="mid01a329c7ee961c9dad03a3b0ac2107e9$1@www.eclipse.org"
type="cite">Thanks for the Answer ... <br>
But I have one problem at lines ...
<br>
<br>
XSDResourceImpl xsdMainResource =
(XSDResourceImpl)resourceSet.createResource(URI.createURI("File.xsd "));
<br>
xsdMainResource.setURI(uri);
<br>
<br>
give me "java.lang.NullPointerException" ....
<br>
<br>
Can you help me ? <br>
Thanks <br>
Marco
<br>
<br>
<br>
</blockquote>
<br>
</body>
</html>

--------------050307030808010402060708--
Re: Load XML Schema from File and extract Types [message #66207 is a reply to message #66186] Mon, 20 February 2006 17:13 Go to previous messageGo to next message
Eclipse User
Originally posted by: marcopk84.yahoo.it

I trying to load a resource.

I add your line but ...

Wrapped exception
java.io.FileNotFoundException: //cache/www.w3.org/2001/MagicXMLSchema.xsd
Re: Load XML Schema from File and extract Types [message #66226 is a reply to message #66207] Mon, 20 February 2006 19:12 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

Marco,

What version of XSD are you using? Have you gotten the example to run?


marcopk wrote:

> I trying to load a resource.
>
> I add your line but ...
>
> Wrapped exception
> java.io.FileNotFoundException: //cache/www.w3.org/2001/MagicXMLSchema.xsd
>
>
>
Re: Load XML Schema from File and extract Types [message #66247 is a reply to message #66226] Mon, 20 February 2006 21:36 Go to previous messageGo to next message
Eclipse User
Originally posted by: marcopk84.yahoo.it

I'm using XSD 2.1.1 ...

The real problem is that when I run the code in a Java Project it works
very well , but when I use it in a Eclipse Plugin Project it give me the
Exception you Know .

Thanks a lot for the answer

Marco
Re: Load XML Schema from File and extract Types [message #66268 is a reply to message #66247] Mon, 20 February 2006 21:42 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

Marco,

Perhaps you don't have the right plugin dependencies set in your plugin
project. Often people will mess with the compiler path to make things
build, but then the same problem comes back at runtime, because the
actual runtime dependencies haven't been specified correctly. You
should only use the dependencies tab of the MANIFEST.MF (or plugin.xml)
to change your runtime and compile time dependencies...


marcopk wrote:

> I'm using XSD 2.1.1 ...
>
> The real problem is that when I run the code in a Java Project it
> works very well , but when I use it in a Eclipse Plugin Project it
> give me the Exception you Know .
>
> Thanks a lot for the answer
>
> Marco
>
Re: Load XML Schema from File and extract Types [message #66287 is a reply to message #66268] Tue, 21 February 2006 17:26 Go to previous message
Eclipse User
Originally posted by: marcopk84.yahoo.it

Thanks for your answer I have resolved my problem !

I have changed the configuration of dependes in "plugin.xml" and now
finally it works very well !

Thanks a lot ,

Marco
Re: Load XML Schema from File and extract Types [message #597620 is a reply to message #66124] Mon, 20 February 2006 13:04 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26054
Registered: July 2009
Senior Member
Load the schema as illustrated in XSDMainExample and use
XSDSchema.getTypeDefinitions to get the list of all types. You'll need
to walk the complex type's complex content (a tree of XSDParticles) to
visit the elements of shiptotype.

marcopk wrote:

> Hello to all !
> it is the first time that I write here......
> I am developing a EditorXml that it allows to validate an XML file xml
> based on the XML Schema contained in a file .xsd !
>
> I'm interested for being able to give some suggestions during the
> writing , I need to load the names of the SympleTag ComplexTag
> declared in .xsd file .
>
> For Example .... if I have an xsd file like this ...
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <xs:simpleType name="stringtype">
> <xs:restriction base="xs:string"/>
> </xs:simpleType>
>
> <xs:simpleType name="inttype">
> <xs:restriction base="xs:positiveInteger"/>
> </xs:simpleType>
>
> <xs:complexType name="shiptotype">
> <xs:sequence>
> <xs:element name="name" type="stringtype"/>
> <xs:element name="address" type="inttype"/>
> <xs:element name="city" type="stringtype"/>
> <xs:element name="country" type="stringtype"/>
> </xs:sequence>
> </xs:complexType>
>
> </xs:schema>
>
> I'm interested to get for example "shiptotype" "name" "address" "city"
> "country" ...... but no "stringtype" or "xs:positiveInteger"
>
> I hope you can help me with suggestion or JavaCode ....
>
> Sorry for my English ...
>
Re: Load XML Schema from File and extract Types [message #597623 is a reply to message #66145] Mon, 20 February 2006 14:49 Go to previous message
Eclipse User
Originally posted by: marcopk84.yahoo.it

Thanks for the Answer ...

But I have one problem at lines ...

XSDResourceImpl xsdMainResource =
(XSDResourceImpl)resourceSet.createResource(URI.createURI("File.xsd "));
xsdMainResource.setURI(uri);

give me "java.lang.NullPointerException" ....

Can you help me ?

Thanks

Marco
Re: Load XML Schema from File and extract Types [message #597627 is a reply to message #66166] Mon, 20 February 2006 16:55 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26054
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050307030808010402060708
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Marco,

It sounds like you haven't registered a resource factory to handle files
with "xsd" extension (as shown in the example):

resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xsd",
new XSDResourceFactoryImpl());

Are you trying to load a resource or create an empty new one?


marcopk wrote:

> Thanks for the Answer ...
> But I have one problem at lines ...
>
> XSDResourceImpl xsdMainResource =
> (XSDResourceImpl)resourceSet.createResource(URI.createURI("File.xsd "));
> xsdMainResource.setURI(uri);
>
> give me "java.lang.NullPointerException" ....
>
> Can you help me ?
> Thanks
> Marco
>
>


--------------050307030808010402060708
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Marco,<br>
<br>
It sounds like you haven't registered a resource factory to handle
files with "xsd" extension (as shown in the example):<br>
<blockquote> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xsd",
new XSDResourceFactoryImpl());<br>
</blockquote>
Are you trying to load a resource or create an empty new one?<br>
<br>
<br>
marcopk wrote:
<blockquote cite="mid01a329c7ee961c9dad03a3b0ac2107e9$1@www.eclipse.org"
type="cite">Thanks for the Answer ... <br>
But I have one problem at lines ...
<br>
<br>
XSDResourceImpl xsdMainResource =
(XSDResourceImpl)resourceSet.createResource(URI.createURI("File.xsd "));
<br>
xsdMainResource.setURI(uri);
<br>
<br>
give me "java.lang.NullPointerException" ....
<br>
<br>
Can you help me ? <br>
Thanks <br>
Marco
<br>
<br>
<br>
</blockquote>
<br>
</body>
</html>

--------------050307030808010402060708--
Re: Load XML Schema from File and extract Types [message #597637 is a reply to message #66186] Mon, 20 February 2006 17:13 Go to previous message
Eclipse User
Originally posted by: marcopk84.yahoo.it

I trying to load a resource.

I add your line but ...

Wrapped exception
java.io.FileNotFoundException: //cache/www.w3.org/2001/MagicXMLSchema.xsd
Re: Load XML Schema from File and extract Types [message #597645 is a reply to message #66207] Mon, 20 February 2006 19:12 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26054
Registered: July 2009
Senior Member
Marco,

What version of XSD are you using? Have you gotten the example to run?


marcopk wrote:

> I trying to load a resource.
>
> I add your line but ...
>
> Wrapped exception
> java.io.FileNotFoundException: //cache/www.w3.org/2001/MagicXMLSchema.xsd
>
>
>
Re: Load XML Schema from File and extract Types [message #597649 is a reply to message #66226] Mon, 20 February 2006 21:36 Go to previous message
Eclipse User
Originally posted by: marcopk84.yahoo.it

I'm using XSD 2.1.1 ...

The real problem is that when I run the code in a Java Project it works
very well , but when I use it in a Eclipse Plugin Project it give me the
Exception you Know .

Thanks a lot for the answer

Marco
Re: Load XML Schema from File and extract Types [message #597657 is a reply to message #66247] Mon, 20 February 2006 21:42 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26054
Registered: July 2009
Senior Member
Marco,

Perhaps you don't have the right plugin dependencies set in your plugin
project. Often people will mess with the compiler path to make things
build, but then the same problem comes back at runtime, because the
actual runtime dependencies haven't been specified correctly. You
should only use the dependencies tab of the MANIFEST.MF (or plugin.xml)
to change your runtime and compile time dependencies...


marcopk wrote:

> I'm using XSD 2.1.1 ...
>
> The real problem is that when I run the code in a Java Project it
> works very well , but when I use it in a Eclipse Plugin Project it
> give me the Exception you Know .
>
> Thanks a lot for the answer
>
> Marco
>
Re: Load XML Schema from File and extract Types [message #597665 is a reply to message #66268] Tue, 21 February 2006 17:26 Go to previous message
Eclipse User
Originally posted by: marcopk84.yahoo.it

Thanks for your answer I have resolved my problem !

I have changed the configuration of dependes in "plugin.xml" and now
finally it works very well !

Thanks a lot ,

Marco
Previous Topic:Load XML Schema from File and extract Types
Next Topic:Does XSD 2.2 support JDK 1.4.2?
Goto Forum:
  


Current Time: Mon Sep 22 06:20:45 GMT 2014

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

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