BEA Systems, Inc.

com.beasys.commerce.axiom.document.ref
Class RefSchemaGenerator

java.lang.Object
  |
  +--com.beasys.commerce.axiom.document.ref.RefSchemaGenerator

public class RefSchemaGenerator
extends java.lang.Object

A utility class which can generate DocumentSchemaDefs from an XML file.

This supports both the "doc-schemas" DTD in http://www.bea.com/servers/dtd/doc-schemas.dtd and the Interwoven datacapture.cfg 4.0 DTD (except for replicants, which are ignored).

When creating an XML parser, this does obey the "org.xml.sax.parser" System property for determining the SAX Parser class. However, this has been tested with the IBM XML4J parser (com.ibm.xml.parser.SAXDriver) and the SUN XML parser (com.sun.xml.parser.Parser) which ship with WLS 5.1. If an error occurs creating the parser, it will use the IBM parser.

Since:
2.0

Constructor Summary
RefSchemaGenerator()
           
 
Method Summary
static void addIWProperty(org.w3c.dom.Element e, DefaultDocumentSchema schema)
          Add a property entry to a schema from an interwoven "item" element.
static void addProperty(org.w3c.dom.Element e, DefaultDocumentSchema schema)
          Add the attribute information in the given "attribute" element (following the doc-schemas DTD) to the specified schema.
static org.xml.sax.Parser createParser()
          Create a SAX parser for use.
static DocumentSchemaDef getIWSchema(org.w3c.dom.Element e)
          Get a DocumentSchemaDef from a "ruleset" IW element.
static java.util.List getIWSchemas(java.lang.String uri, org.w3c.dom.Element root)
          Get the list of DocumentSchemaDefs from the Interwoven datacapture DTD element.
static DefaultDocumentSchema getSchema(org.w3c.dom.Element e)
          Get a DefaultDocumentSchema from a Element following the doc-schemas DTD.
static java.util.List getSchemas(java.lang.String uri)
          Get a list of DocumentSchemaDefs from the XML at path.
static java.util.List getSchemas(java.lang.String uri, org.w3c.dom.Element root)
          Get the list of DocumentSchemaDefs from the doc-schemas DTD element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RefSchemaGenerator

public RefSchemaGenerator()
Method Detail

getSchemas

public static java.util.List getSchemas(java.lang.String uri)
                                 throws DocumentException
Get a list of DocumentSchemaDefs from the XML at path.

Currently, that XML must be either of the doc-schemas DTD or the Interwoven datacapture DTD. If the document structure is wrong at any point, the schema will be completely ignored.

Parameters:
uri - the URI to the xml.
Returns:
the list of DocumentSchemaDefs.
Throws:
DocumentException - thrown on a parsing error or invalid XML.

getSchemas

public static java.util.List getSchemas(java.lang.String uri,
                                        org.w3c.dom.Element root)
                                 throws DocumentException
Get the list of DocumentSchemaDefs from the doc-schemas DTD element.
Parameters:
root - the "doc-schemas" Element.
Returns:
a list of the DocumentSchemaDefs.
Throws:
DocumentException - thrown on an unrecoverable error getting the schemas.

getSchema

public static DefaultDocumentSchema getSchema(org.w3c.dom.Element e)
                                       throws DocumentException
Get a DefaultDocumentSchema from a Element following the doc-schemas DTD.
Parameters:
e - the "doc-schema" Element.
Returns:
a DefaultDocumentSchema of the schema described in the element.
Throws:
DocumentException - thrown in invalid XML.

addProperty

public static void addProperty(org.w3c.dom.Element e,
                               DefaultDocumentSchema schema)
                        throws DocumentException
Add the attribute information in the given "attribute" element (following the doc-schemas DTD) to the specified schema.

This will throw a DocumentException on any error (i.e. it will not try to do its best with what it has, but will stop on any problem).

Parameters:
e - the "attribute" element.
schema - the schema to add the property info to.
Throws:
DocumentException - thrown on any invalid XML.

getIWSchemas

public static java.util.List getIWSchemas(java.lang.String uri,
                                          org.w3c.dom.Element root)
                                   throws DocumentException
Get the list of DocumentSchemaDefs from the Interwoven datacapture DTD element.

getIWSchema

public static DocumentSchemaDef getIWSchema(org.w3c.dom.Element e)
                                     throws DocumentException
Get a DocumentSchemaDef from a "ruleset" IW element.

addIWProperty

public static void addIWProperty(org.w3c.dom.Element e,
                                 DefaultDocumentSchema schema)
                          throws DocumentException
Add a property entry to a schema from an interwoven "item" element.

For now, we're not going to investigate the "item" any further. This means replicants and options are ignored.


createParser

public static org.xml.sax.Parser createParser()
                                       throws DocumentException
Create a SAX parser for use.

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved