|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.xsd.util.XSDSchemaQueryTools
public abstract class XSDSchemaQueryTools
XSDSchemaQueryTools is a collection of worker methods for performing simple queries or searches of schemas.
These are suitable to show examples of how to build convenience methods to more easily find components in a schema. They also serve as useful examples of usage of the library's functions.
Note that these methods are somewhat simplistic, especially in terms of support for namespaces. To simplify the calling signatures, and to account for the 80% case where you don't have multiple namespaces, most method simply take a localName that's assumed to be correct in the current context. However it should be simple to copy & paste these methods and add namespaceURI's to each method if desired.
Constructor Summary | |
---|---|
XSDSchemaQueryTools()
|
Method Summary | |
---|---|
static java.util.List<XSDElementDeclaration> |
findElementsUsingType(XSDSchema schema,
java.lang.String namespace,
java.lang.String localName)
Find elementDeclarations that use any types derived from a named type. |
static java.util.List<XSDTypeDefinition> |
findTypesDerivedFrom(XSDSchema schema,
java.lang.String namespace,
java.lang.String localName)
Find typeDefinitions that derive from a named type. |
static java.util.HashMap<java.lang.String,java.lang.String> |
hasImpInclRedef(XSDSchema schema)
Find any included, imported, or redefined schemas that this one references. |
static java.util.HashMap<java.lang.String,java.lang.String> |
hasImpInclRedef2(XSDSchema schema)
Find any included, imported, or redefined schemas that this one references. |
static boolean |
isTypeDerivedFrom(XSDTypeDefinition typedef,
java.lang.String namespace,
java.lang.String localName)
Recursive worker method to find typeDefinitions that derive from a named type. |
protected static void |
mapImpInclRedef(XSDSchema schema,
java.util.HashMap<java.lang.String,java.lang.String> hash,
int level)
Recursive worker method implementing hasImpInclRedef(XSDSchema)
and hasImpInclRedef2(XSDSchema) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XSDSchemaQueryTools()
Method Detail |
---|
public static java.util.List<XSDTypeDefinition> findTypesDerivedFrom(XSDSchema schema, java.lang.String namespace, java.lang.String localName)
This shows one way to query the schema for typeDefinitions and then how to find specific kinds of typeDefinitions.
schema
- to search for typeDefsnamespace
- for the type derived fromlocalName
- for the type derived from
public static boolean isTypeDerivedFrom(XSDTypeDefinition typedef, java.lang.String namespace, java.lang.String localName)
This is not a terribly time-efficient algorithim, but it does show usage of library methods. This works for simpleTypes; complexType support needs to be added.
typedef
- to see if it's derived fromnamespace
- for the type derived fromlocalName
- for the type derived from
findTypesDerivedFrom(XSDSchema, String, String)
public static java.util.List<XSDElementDeclaration> findElementsUsingType(XSDSchema schema, java.lang.String namespace, java.lang.String localName)
This shows one way to query the schema for elementDeclarations and then how to find specific kinds of typeDefinitions.
schema
- to search for elemDeclsnamespace
- for the type usedlocalName
- for the type used
public static java.util.HashMap<java.lang.String,java.lang.String> hasImpInclRedef(XSDSchema schema)
This method uses solely the Schema model API to look for XSDSchemaDirective objects. Each directive is the result of an include, import, or redefine in our schema. We then walk the tree of directives, finding their resolved schemas (if available), and produce a simple HashMap of them all.
See also hasImpInclRedef2(XSDSchema)
which uses the underlying ResourceSet model to query the
external resources that were loaded with this schema: it
has the same effect, but using different code.
schema
- object to search for imports/includes/redefines
hasImpInclRedef2(XSDSchema)
public static java.util.HashMap<java.lang.String,java.lang.String> hasImpInclRedef2(XSDSchema schema)
This method uses the underlying ResourceSet model to query the external resources that were loaded with this schema. Note that the ResourceSet implementation is subject to change.
schema
- object to search for imports/includes/redefines
hasImpInclRedef(XSDSchema)
protected static void mapImpInclRedef(XSDSchema schema, java.util.HashMap<java.lang.String,java.lang.String> hash, int level)
hasImpInclRedef(XSDSchema)
and hasImpInclRedef2(XSDSchema)
.
This uses only the schema model library API's to look for XSDSchemaDirective objects in it's content. It then checks which specific subclass of directive each is to report and then recurses to any other schemas found.
schema
- object to search for imports/includes/redefineshash
- where keys are the URI's of any other schemas
found, and values are one of 'import', 'include', 'redefine';
this object is mutated by this methodlevel
- of iteration we're on
|
Copyright 2001-2006 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |