Creating new xml schema file example ? [message #986] |
Tue, 24 September 2002 11:15  |
Eclipse User |
|
|
|
Originally posted by: v.nisevic.mobilkom.at
Could you please show, how to create a simple xml schema file, with this
framework, including writing it to the file system. I cannot find enough
information classes org.eclipse.xsd.util
Thanks !
E.g.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="book">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
<xs:element name="character" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="friend-of" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="since" type="xs:date"/>
<xs:element name="qualification" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="isbn" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:schema>
|
|
|
Re: Creating new xml schema file example ? [message #1015 is a reply to message #986] |
Wed, 25 September 2002 14:39   |
Eclipse User |
|
|
|
Example code showing the fundamentals of creating a schema and saving it are indeed in the org.eclipse.xsd.util package - have
you looked through the Javadoc for XSDPrototypicalSchema yet? In particular see:
savePurchaseOrderSchema(...) for a way to save an XSDSchema object to a URI by asking the ResourceSet framework to save it for
you;
printSchema(...)/printComponent(...) for a way to save an XSDSchema object by getting it's underlying concrete DOM object and
asking Xerces to directly serialize it for you;
the various initialize...() methods, that show how to build some sample schemas bit-by-bit.
Also, see the XSDSchemaBuildingTools.java for a set of very simplistic convenience methods that allow you to create basic
elements, attrs, etc, using single method calls to this wrapper instead of multiple calls to the library directly. Note that
while some of these methods have limited namespace support, they do show the kind of way that a simpler API for building
schemas could be built on top of the rich detail that the org.eclipse.xsd package provides.
- Shane
|
|
|
Re: Creating new xml schema file example ? [message #562481 is a reply to message #986] |
Wed, 25 September 2002 14:39   |
Eclipse User |
|
|
|
Example code showing the fundamentals of creating a schema and saving it are indeed in the org.eclipse.xsd.util package - have
you looked through the Javadoc for XSDPrototypicalSchema yet? In particular see:
savePurchaseOrderSchema(...) for a way to save an XSDSchema object to a URI by asking the ResourceSet framework to save it for
you;
printSchema(...)/printComponent(...) for a way to save an XSDSchema object by getting it's underlying concrete DOM object and
asking Xerces to directly serialize it for you;
the various initialize...() methods, that show how to build some sample schemas bit-by-bit.
Also, see the XSDSchemaBuildingTools.java for a set of very simplistic convenience methods that allow you to create basic
elements, attrs, etc, using single method calls to this wrapper instead of multiple calls to the library directly. Note that
while some of these methods have limited namespace support, they do show the kind of way that a simpler API for building
schemas could be built on top of the rich detail that the org.eclipse.xsd package provides.
- Shane
|
|
|
|
Powered by
FUDForum. Page generated in 0.04408 seconds