Load XML Schema from File and extract Types [message #66124] |
Sun, 19 February 2006 11:35 |
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 |
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 |
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 |
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 #66226 is a reply to message #66207] |
Mon, 20 February 2006 19:12 |
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 |
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 |
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 #597620 is a reply to message #66124] |
Mon, 20 February 2006 13:04 |
Ed Merks Messages: 33216 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 ...
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Load XML Schema from File and extract Types [message #597623 is a reply to message #66145] |
Mon, 20 February 2006 14:49 |
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 |
Ed Merks Messages: 33216 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--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
Re: Load XML Schema from File and extract Types [message #597649 is a reply to message #66226] |
Mon, 20 February 2006 21:36 |
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 |
Ed Merks Messages: 33216 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
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.04952 seconds