Hello,
I have an xsd file, and I would like to read its structure and display it as a JTree.
I know there are DOM and SAX parsers, but Im looking for something that would detect simple/complex types etc.
Is there any library able to do this? I know C# has XMLSchema, but I have to write in Java.
Cheers,
Charles
4 11547 Dököll 2,364
Recognized Expert Top Contributor
Java can do anything...
I thought to have seen somethings, give me a minute!
Dököll 2,364
Recognized Expert Top Contributor
Java can do anything...
I thought to have seen somethings, give me a minute!
Try this, I believe what you aksed for is this. Posting code instead, just in case link no longer works: -
/**
-
* Author: Fuhwei Lwo
-
*/
-
import java.io.FileOutputStream;
-
import java.io.FileInputStream;
-
import java.io.OutputStream;
-
-
import commonj.sdo.DataObject;
-
import commonj.sdo.helper.DataFactory;
-
import commonj.sdo.helper.XMLHelper;
-
import commonj.sdo.helper.XSDHelper;
-
-
public class CreatePurchaseOrder {
-
private static final String PO_MODEL = "po.xsd";
-
private static final String PO_NAMESPACE = "http://www.example.com/PO";
-
private static final String PO_XML = "po.xml";
-
-
private static void definePOTypes() throws Exception {
-
FileInputStream fis = new FileInputStream(PO_MODEL);
-
XSDHelper.INSTANCE.define(fis, null);
-
fis.close();
-
}
-
-
public static void main(String[] args) throws Exception {
-
definePOTypes();
-
-
DataObject purchaseOrder =
-
DataFactory.INSTANCE.create(PO_NAMESPACE, "PurchaseOrderType");
-
-
purchaseOrder.setString("orderDate", "1999-10-20");
-
-
DataObject shipTo = purchaseOrder.createDataObject("shipTo");
-
shipTo.set("country", "US");
-
shipTo.set("name", "Alice Smith");
-
shipTo.set("street", "123 Maple Street");
-
shipTo.set("city", "Mill Valley");
-
shipTo.set("state", "CA");
-
shipTo.setString("zip", "90952");
-
DataObject billTo = purchaseOrder.createDataObject("billTo");
-
billTo.set("country", "US");
-
billTo.set("name", "Robert Smith");
-
billTo.set("street", "8 Oak Avenue");
-
billTo.set("city", "Mill Valley");
-
billTo.set("state", "PA");
-
billTo.setString("zip", "95819");
-
purchaseOrder.set("comment", "Hurry, my lawn is going wild!");
-
-
DataObject items = purchaseOrder.createDataObject("items");
-
-
DataObject item1 = items.createDataObject("item");
-
item1.set("partNum", "872-AA");
-
item1.set("productName", "Lawnmower");
-
item1.setInt("quantity", 1);
-
item1.setString("USPrice", "148.95");
-
item1.set("comment", "Confirm this is electric");
-
-
DataObject item2 = items.createDataObject("item");
-
item2.set("partNum", "926-AA");
-
item2.set("productName", "Baby Monitor");
-
iteim2.setInt("quantity", 1);
-
item2.setString("USPrice", "39.98");
-
item2.setString("shipDate", "1999-05-21");
-
-
OutputStream stream = new FileOutputStream(PO_XML);
-
XMLHelper.INSTANCE.save(purchaseOrder, PO_NAMESPACE, "purchaseOrder", stream);
-
}
-
}
-
Not sure of the legality of this, have not tried it myself, but I trust IBM:-) Here is the link: http://www.ibm.com/developerworks/xm...ema/index.html
In a bit!
Thanks a lot! This was really helpful ;)
Dököll 2,364
Recognized Expert Top Contributor
Thanks a lot! This was really helpful ;)
Excellent, have fun:-)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Krzysztof Pa¼ |
last post by:
Hi,
I want to make simple client in phyton, which would be able to communicate
with Java server using SSL sockets.
There is the Java clients, which is doing this - so I'm pretty sure, that
Java...
|
by: Maurice LING |
last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic
typing, is there any other real reasons that Python is slower than Java?
maurice
|
by: Gaurav |
last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250
Any comments?
Thanks
Gaurav
|
by: napi |
last post by:
I think you would agree with me that a C compiler that directly
produces Java Byte Code to be run on any JVM is something that is
missing to software programmers so far. With such a tool one could...
|
by: sbalko |
last post by:
Hi,
I am trying to read Java-floats (IEEE 754 encoding) stored in a binary
file from C (gcc on linux/i386, more specifically). Unfortunately, C
seems to expect floats to be stored somewhat...
| |
by: David Van D |
last post by:
Hi there,
A few weeks until I begin my journey towards a degree in Computer
Science at Canterbury University in New Zealand,
Anyway the course tutors are going to be teaching us JAVA wth bluej...
|
by: gm04030276 |
last post by:
i have to learn java for college and im trying to do a programming assignment at home. in class we use a class file called InOut which simplifys input and output but i can't get the compiler to see...
|
by: Xah Lee |
last post by:
On Java's Interface
Xah Lee, 20050223
In Java the language, there's this a keyword “interfaceâ€.
In a functional language, a function can be specified by its name and
parameter specs....
|
by: blazedaces |
last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing...
|
by: sapsi |
last post by:
Hello,
I am using HadoopStreaming using a BinaryInputStream. What this
basically does is send a stream of bytes ( the java type is : private
byte bytes) to my python program.
I have done a...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |