public final class SchemaMapping
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
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.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SCHEMAS_FILE
default name of the file containing schema mapping rules
|
Constructor and Description |
---|
SchemaMapping()
empty mapping
|
SchemaMapping(java.net.URI baseURI)
empty mapping
|
Modifier and Type | Method and Description |
---|---|
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) |
public static final java.lang.String SCHEMAS_FILE
public SchemaMapping()
public SchemaMapping(java.net.URI baseURI)
baseURI
- url to resolve relative URLs in this documentpublic 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 addpublic 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 returnedpublic 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 documentpublic 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 schemajava.lang.IllegalArgumentException
- if the url is nulljava.io.IOException
org.xml.sax.SAXException
public void toDocument(java.lang.String output) throws java.io.IOException
output
- url to the output filejava.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)