edu.ucsb.nceas.metacat.service
Class XMLSchemaService

java.lang.Object
  extended by edu.ucsb.nceas.metacat.shared.BaseService
      extended by edu.ucsb.nceas.metacat.service.XMLSchemaService

public class XMLSchemaService
extends BaseService


Field Summary
static java.lang.String NAMESPACEKEYWORD
           
static java.lang.String SCHEMA_DIR
           
 
Fields inherited from class edu.ucsb.nceas.metacat.shared.BaseService
_serviceName
 
Method Summary
static boolean areAllSchemasRegistered(java.util.Vector<XMLSchema> schemaList)
          Checks to see that all schemas are registered.
 void doRefresh()
          refresh the persistant values in this service.
static java.lang.String findDocumentNamespace(java.io.StringReader xml)
          Returns all the namespace for an xml document.
static java.util.Vector<XMLSchema> findSchemasInXML(java.io.StringReader xml)
          See if schemas have been specified in the xml:schemalocation attribute.
static XMLSchemaService getInstance()
          Get the single instance of XMLService.
static java.lang.String getNameSpaceAndLocationString()
          Gets the name space and location string.
static java.util.Vector<java.lang.String> getNameSpaceList()
          Gets a list of name spaces.
static java.util.Vector<XMLSchema> getRegisteredSchemaList()
          Gets the registered schema list.
static java.lang.String getSchemaFileNameFromUri(java.lang.String uri)
          Get a schema file name from the schema uri.
static boolean isSchemaRegistered(XMLSchema xmlSchema)
          Returns true if the schema is registered.
static void populateRegisteredSchemaList()
          Populate the list of registered schemas.
 boolean refreshable()
           
 void stop()
           
static boolean useFullSchemaValidation()
          Report whether xml parsing is set to use full schema parsing.
 
Methods inherited from class edu.ucsb.nceas.metacat.shared.BaseService
refresh
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACEKEYWORD

public static final java.lang.String NAMESPACEKEYWORD
See Also:
Constant Field Values

SCHEMA_DIR

public static final java.lang.String SCHEMA_DIR
See Also:
Constant Field Values
Method Detail

getInstance

public static XMLSchemaService getInstance()
Get the single instance of XMLService.

Returns:
the single instance of XMLService

refreshable

public boolean refreshable()
Specified by:
refreshable in class BaseService

doRefresh

public void doRefresh()
               throws ServiceException
refresh the persistant values in this service.

Specified by:
doRefresh in class BaseService
Throws:
ServiceException

stop

public void stop()
          throws ServiceException
Specified by:
stop in class BaseService
Throws:
ServiceException

getRegisteredSchemaList

public static java.util.Vector<XMLSchema> getRegisteredSchemaList()
Gets the registered schema list. This list holds schemas that exist in the xml_catalog table that also have associated files in the schema directory.

Returns:
a list of XMLSchema objects holding registered schema information

getNameSpaceAndLocationString

public static java.lang.String getNameSpaceAndLocationString()
Gets the name space and location string. This is a convenience method. The string will have space delimited namespaces and locations that are held in the registered schema list.

Returns:
a string that holds space delimited registered namespaces and locations.

getNameSpaceList

public static java.util.Vector<java.lang.String> getNameSpaceList()
Gets a list of name spaces. This is a convenience method. The list will have all namespaces that are held in the registered schema list.

Returns:
a list that holds registered namespaces.

useFullSchemaValidation

public static boolean useFullSchemaValidation()
Report whether xml parsing is set to use full schema parsing. If full schema parsing is true, new schemas will be validated before being entered into the database and file system.

Returns:
true if the xml.useFullSchemaValidation property is set to true, false otherwise.

populateRegisteredSchemaList

public static void populateRegisteredSchemaList()
Populate the list of registered schemas. This reads all schemas in the xml_catalog table and then makes sure the schema actually exists and is readable on disk.


areAllSchemasRegistered

public static boolean areAllSchemasRegistered(java.util.Vector<XMLSchema> schemaList)
Checks to see that all schemas are registered. If a single one in the list is not, this will return false.

Parameters:
schemaList - a list of schemas as they appear in xml.
Returns:
true if all schemas are registered.

isSchemaRegistered

public static boolean isSchemaRegistered(XMLSchema xmlSchema)
Returns true if the schema is registered.

Parameters:
schema - a single schema as it appears in xml
Returns:
true if the schema is registered, false otherwise.

findSchemasInXML

public static java.util.Vector<XMLSchema> findSchemasInXML(java.io.StringReader xml)
                                                    throws java.io.IOException
See if schemas have been specified in the xml:schemalocation attribute. If so, return a vector of the system ids.

Parameters:
xml - the document we want to look in for schema location
Returns:
a vector of XMLSchema objects, or an empty vector if none are found
Throws:
java.io.IOException

findDocumentNamespace

public static java.lang.String findDocumentNamespace(java.io.StringReader xml)
                                              throws java.io.IOException
Returns all the namespace for an xml document. This is done by getting the internal namespace declaration (prefix) and looking for xmlns:

Parameters:
xml - the document to search
Returns:
a string holding the namespace
Throws:
java.io.IOException

getSchemaFileNameFromUri

public static java.lang.String getSchemaFileNameFromUri(java.lang.String uri)
Get a schema file name from the schema uri.

Parameters:
uri - the uri from which to extract the file name
Returns:
a string holding the file name


Copyright © 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.