|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectxml.parser.SchemaMapping
public final class SchemaMapping
keeps rules to map a schema to a given instance document. The schema mapping can be serialized in a "schemas.xml" file, compatible with the nXML emacs mode written by James Clark. TODO: some features are still missing (apply following rule) TODO: with XSD, one has to specify one schema per namespace, it is not supported by this implementation.
| Nested Class Summary | |
|---|---|
static class |
SchemaMapping.DefaultRule
always matches : not really useful for us, is it ? |
static class |
SchemaMapping.DoctypeRule
doctype -> typeID or URL. |
static class |
SchemaMapping.DocumentElementRule
prefix + localName -> typeId or URL |
static class |
SchemaMapping.IncludeMapping
|
static class |
SchemaMapping.Mapping
|
static class |
SchemaMapping.NamespaceRule
namespace -> typeId or URL |
static class |
SchemaMapping.Result
|
static class |
SchemaMapping.TransformURI
URI pattern -> related URL. |
static class |
SchemaMapping.TypeIdMapping
models the typeId element in schemas.xml |
static class |
SchemaMapping.URIPatternRule
URI pattern -> typeID or URL. |
static class |
SchemaMapping.URIResourceRule
URI -> typeId or URL. |
| Field Summary | |
|---|---|
static java.lang.String |
SCHEMAS_FILE
default name of the file containing schema mapping rules |
| Constructor Summary | |
|---|---|
SchemaMapping()
empty mapping |
|
SchemaMapping(java.net.URI baseURI)
empty mapping |
|
| Method Summary | |
|---|---|
void |
addRule(SchemaMapping.Mapping r)
manually add a rule |
void |
addTypeId(java.lang.String tid,
java.lang.String target,
boolean targetIsTypeId)
manually add a typeId mapping. |
boolean |
ensureIncluded(SchemaMapping mapping)
|
static SchemaMapping |
fromDocument(java.lang.String url,
org.xml.sax.ErrorHandler errorHandler)
deserialize an xml document describing the mapping rules (schemas.xml) |
java.net.URI |
getBaseURI()
|
SchemaMapping.Mapping |
getMappingForDocument(java.lang.String publicId,
java.lang.String systemId,
java.lang.String namespace,
java.lang.String prefix,
java.lang.String localName)
iterate over the mappings and return the first hit. |
java.util.List<SchemaMapping.Mapping> |
getRules()
|
SchemaMapping.Result |
getSchemaForDocument(java.lang.String publicId,
java.lang.String systemId,
java.lang.String namespace,
java.lang.String prefix,
java.lang.String localName,
boolean followTypeId)
iterate over the mappings and return the first hit. |
java.lang.String |
getTypeIdForDocument(java.lang.String resourceURL)
|
java.util.List<SchemaMapping.TypeIdMapping> |
getTypeIds()
|
void |
insertRuleAt(int pos,
SchemaMapping.Mapping m)
|
void |
removeRule(SchemaMapping.Mapping m)
|
void |
removeRuleAt(int pos)
|
SchemaMapping.Result |
resolveTypeId(java.lang.String tid)
|
static boolean |
resourceExists(java.net.URI resource)
try to use the VFS to detect if a resource exists |
void |
toDocument(java.lang.String output)
serialize to an XML document |
void |
updateMapping(SchemaMapping.URIResourceRule newRule)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String SCHEMAS_FILE
| Constructor Detail |
|---|
public SchemaMapping()
public SchemaMapping(java.net.URI baseURI)
baseURI - url to resolve relative URLs in this document| Method Detail |
|---|
public java.net.URI getBaseURI()
public void insertRuleAt(int pos,
SchemaMapping.Mapping m)
public void removeRule(SchemaMapping.Mapping m)
public void removeRuleAt(int pos)
public void updateMapping(SchemaMapping.URIResourceRule newRule)
public boolean ensureIncluded(SchemaMapping mapping)
public java.lang.String getTypeIdForDocument(java.lang.String resourceURL)
public SchemaMapping.Result resolveTypeId(java.lang.String tid)
tid - the type identifier to look up (try "RNG")
public void addRule(SchemaMapping.Mapping r)
r - rule to add
public void addTypeId(java.lang.String tid,
java.lang.String target,
boolean targetIsTypeId)
tid - typeIdtarget - target url or typeIdtargetIsTypeId - is the target itself a type id ?public java.util.List<SchemaMapping.TypeIdMapping> getTypeIds()
public java.util.List<SchemaMapping.Mapping> getRules()
public SchemaMapping.Result getSchemaForDocument(java.lang.String publicId,
java.lang.String systemId,
java.lang.String namespace,
java.lang.String prefix,
java.lang.String localName,
boolean followTypeId)
publicId - public ID of the parsed documentsystemId - system ID of the parsed documentnamespace - namespace of the root element of the parsed documentprefix - prefix of the root element of the parsed documentlocalName - localName of the root element of the parsed documentfollowTypeId - if the schema referenced from the typeId should be returned
public SchemaMapping.Mapping getMappingForDocument(java.lang.String publicId,
java.lang.String systemId,
java.lang.String namespace,
java.lang.String prefix,
java.lang.String localName)
publicId - public ID of the parsed documentsystemId - system ID of the parsed documentnamespace - namespace of the root element of the parsed documentprefix - prefix of the root element of the parsed documentlocalName - localName of the root element of the parsed document
public static SchemaMapping fromDocument(java.lang.String url,
org.xml.sax.ErrorHandler errorHandler)
throws java.io.IOException,
org.xml.sax.SAXException,
java.lang.IllegalArgumentException
url - url of the document to readerrorHandler - error handler notified of errors encountered when loading the schema
java.lang.IllegalArgumentException - if the url is null
java.io.IOException
org.xml.sax.SAXException
public void toDocument(java.lang.String output)
throws java.io.IOException
output - url to the output file
java.io.IOException - if there is an error during serialization
FIXME: serialized document could be invalid. Is it worth using proper XML serialization ?public static boolean resourceExists(java.net.URI resource)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||