org.exolab.castor.xml.dtd
Class Converter
java.lang.Object
org.exolab.castor.xml.dtd.Converter
public class Converter
extends java.lang.Object
Class containing static top-level methods to parse and convert
XML DTD documents to corresponding XML Schema documents.
Also contains simple command line interface to read
an XML DTD file and create corresponding XML Schema object.
$Revision: 1.2 $ $Date: 2003/03/03 09:57:18 $
convertAttribute
public static AttributeDecl convertAttribute(Attribute dtdAttribute,
Schema schema)
throws DTDException
Convert DTD Attribute declaration to Schema Attribute Declaration.
dtdAttribute
- DTD Attribute declaration.schema
- Schema owning Element of this Attribute.
- corresponding Schema Attribute declaration.
DTDException
- if the input DTD Attribute Declaration is malformed.
convertDTDElementToSchemaElement
public static ElementDecl convertDTDElementToSchemaElement(Element dtdElement,
Schema schema)
throws DTDException,
SchemaException
Convert DTD Element declaration to Schema Element Declaration.
dtdElement
- DTD Element declaration.schema
- Schema owning Element declaration.
- corresponding Schema Element declaration.
convertDTDObjectToSchemaObject
public static Schema convertDTDObjectToSchemaObject(DTDdocument dtd)
throws DTDException,
SchemaException
Convert DTD document object to corresponding Schema object.
dtd
- input XML DTD document object.
- corresponding XML Schema object.
convertDTDtoSchema
public static void convertDTDtoSchema(Reader reader,
Writer writer)
throws DTDException,
SchemaException,
IOException,
SAXException
Convert DTD document to corresponding XML Schema document.
reader
- reader of the input DTD document.writer
- writer to the output Schema document.
main
public static void main(args[] )
throws IOException,
DTDException,
SchemaException,
SAXException
Simple command line interface to read an XML DTD file and create
corresponding XML Schema file. Usage:
java org.exolab.castor.xml.dtd.Converter dtd_file xsd_file [character_encoding]
dtd_file: name of the input DTD file
xsd_file: name of the output Schema file
character_encoding: name of the character encoding,
if not specified, ASCII is chosen
Help message is provided.
marshalSchema
public static void marshalSchema(Schema schema,
Writer writer)
throws IOException,
SAXException
Marshals XML Schema to output char stream.
schema
- XML Schema object to marshal.writer
- output char stream to marshal Schema to.
parseDTD
public static DTDdocument parseDTD(Reader reader)
throws DTDException
Parses text of a DTD document and returns corresponding DTD document object.
It is left to constructor of the reader to set up
character encoding correctly. This means that method
read of
the reader is used to get next character, assuming it returns
appropriate values.
reader
- input char stream reader. It is recommended
to use class java.io.InputStreamReader
as a reader, which allows to set desired character encoding.
- DTD document object corresponding to the input text
of a DTD document.
DTDException
- if the DTD document is syntactically or semanticly
not correct.
Intalio Inc. (C) 1999-2003. All rights reserved http://www.intalio.com