org.idoox.xml.schema
Interface SchemaParser


public interface SchemaParser

Implementations of this interface are responsible for parsing schema document into an instance of Schema object.

The typical usage of schema parser is:

Since:
1.0
Component:
Core

Method Summary
 java.util.Map getNamespaceLocationMap()
          Returns the map from namespaceURI(String) -> Location(String) of the schema.
 Schema getSchema()
          Resolves all pending unresolved references and returns a representation of loaded schema.
 java.lang.String getSchemaLocation(java.lang.String targetNamespace)
          Gets physical schema location for the given namespace.
 java.util.Iterator getUnresolvedAttributeGroups()
          Returns an iterator of unresolved attribute groups or null if all attribute groups are resolved.
 java.util.Iterator getUnresolvedAttributes()
          Returns an iterator of unresolved attributes or null if all attributes are resolved.
 java.util.Iterator getUnresolvedElements()
          Returns an iterator of unresolved elements or null if all elements are resolved.
 java.util.Iterator getUnresolvedGroups()
          Returns an iterator of unresolved groups or null if all groups are resolved.
 java.util.Iterator getUnresolvedTypes()
          Returns an iterator of unresolved types or null if all types are resolved.
 boolean isParsingFacets()
          Returns true if the parser stores facets.
 void parse(org.w3c.dom.Element element, Endpoint schemaLocation)
          Parses in an already loaded schema document.
 void parse(Endpoint schemaLocation)
          Parses in a schema document.
 void parse(java.lang.String namespaceURI)
          Parses in a schema document.
 void parseLocation(java.lang.String url)
          Parses in a schema document from the given location URL.
 void resolve()
          Resolves all pending unresolved references.
 void setHostTransportProperties(java.lang.String host, java.util.Map transportProperties)
          Sets up the transport properties (i.e.
 void setNamespaceLocationMap(java.util.Map namespaceLocationMap)
          Sets the schema location map.
 void setParsingFacets(boolean parsingFacets)
          Instructs the parser (not) to parse and store facets.
 

Method Detail

parse

public void parse(java.lang.String namespaceURI)
           throws SchemaException
Parses in a schema document.

Parameters:
namespaceURI - the namespaceURI of the schema document. Theree must be a mapping between namespace and document's location in the schemaLocationMap. See get/setNamespaceLocationMap.
Throws:
SchemaException - if the namespace could not be loaded.

parse

public void parse(Endpoint schemaLocation)
           throws SchemaException
Parses in a schema document.

Parameters:
schemaLocation - the location of the schema; the string shouldn't be URL encoded (see #25403)
Throws:
SchemaException - if something goes wrong

parseLocation

public void parseLocation(java.lang.String url)
                   throws SchemaException
Parses in a schema document from the given location URL.

Parameters:
url - the location of the schema
Throws:
SchemaException - if something goes wrong

parse

public void parse(org.w3c.dom.Element element,
                  Endpoint schemaLocation)
           throws SchemaException
Parses in an already loaded schema document.

Parameters:
element - the already-loaded schema document
schemaLocation - location of the schema document, will be used as base for relative references.
Throws:
SchemaException - if there is an error in the schema.

getUnresolvedTypes

public java.util.Iterator getUnresolvedTypes()
Returns an iterator of unresolved types or null if all types are resolved.

Returns:
the iterator of unresolved types

getUnresolvedElements

public java.util.Iterator getUnresolvedElements()
Returns an iterator of unresolved elements or null if all elements are resolved.

Returns:
the iterator of unresolved elements

getUnresolvedGroups

public java.util.Iterator getUnresolvedGroups()
Returns an iterator of unresolved groups or null if all groups are resolved.

Returns:
the iterator of unresolved groups

getUnresolvedAttributes

public java.util.Iterator getUnresolvedAttributes()
Returns an iterator of unresolved attributes or null if all attributes are resolved.

Returns:
an iterator of unresolved attributes

getUnresolvedAttributeGroups

public java.util.Iterator getUnresolvedAttributeGroups()
Returns an iterator of unresolved attribute groups or null if all attribute groups are resolved.

Returns:
an iterator of unresolved attribute groups

resolve

public void resolve()
             throws SchemaException
Resolves all pending unresolved references.

Throws:
SchemaException - if the resolve has not been successful

getSchema

public Schema getSchema()
                 throws SchemaException
Resolves all pending unresolved references and returns a representation of loaded schema.

Returns:
the representation of loaded schema
Throws:
SchemaException - if there were unresolved (and unresolvable) references.

getNamespaceLocationMap

public java.util.Map getNamespaceLocationMap()
Returns the map from namespaceURI(String) -> Location(String) of the schema.

Returns:
the map of namespace location

setNamespaceLocationMap

public void setNamespaceLocationMap(java.util.Map namespaceLocationMap)
Sets the schema location map.

Parameters:
namespaceLocationMap - map of schema location [namespaceURI(String) -> Location(String)]

isParsingFacets

public boolean isParsingFacets()
Returns true if the parser stores facets.

After parsing, they can be obtained using getFacets() on SchemaConstruct.


setParsingFacets

public void setParsingFacets(boolean parsingFacets)
Instructs the parser (not) to parse and store facets.

Parameters:
parsingFacets - true if the parser should store facets

setHostTransportProperties

public void setHostTransportProperties(java.lang.String host,
                                       java.util.Map transportProperties)
Sets up the transport properties (i.e. HTTP basic password) to use when getting downloading XML Schema document from the specified host.

Parameters:
host - host name; if null the call has no effect
transportProperties - can be null; properties that will be used for the host from this moment; the map is never modified by SchemaParser

getSchemaLocation

public java.lang.String getSchemaLocation(java.lang.String targetNamespace)
Gets physical schema location for the given namespace. Useful to determine whether physical location is known for some schema namespace for example when creating import.

Parameters:
targetNamespace - targetNamespace of some XML Schema
Returns:
location of the schema; can return null if location is unknown