|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.dlese.dpc.xml.schema.SchemaHelper
public class SchemaHelper
Class encapsluting semantics of XML Schemas.
Aggregates tools and data structures for working with XML Schemas, and is in
turn encapsulated in the MetaDataFramework
object. Major components include
XSDatatypeManager
for performing
iterative validation of xml documents using datatypes defined in the
Schema.DefinitionMiner
which traverses an
XML Schema and builds a dictionary of GlobalElement
objects, one for each element defined in the Schema.SchemaNodeMap
that represents the
structure defined by the Schema as a tree of SchemaNode
objects.NOTE: The SchemaHelper assumes that XML Schemas are represented using the "Venetian Blind" technique.
Field Summary | |
---|---|
static int |
MAXOCCURS_DEFAULT
NOT YET DOCUMENTED |
static int |
MINOCCURS_DEFAULT
NOT YET DOCUMENTED |
static String |
NILLABLE_DEFAULT
NOT YET DOCUMENTED |
static int |
UNBOUNDED
NOT YET DOCUMENTED |
Constructor Summary | |
---|---|
SchemaHelper(File schemaFile)
Constructor for the SchemaHelper object |
|
SchemaHelper(File schemaFile,
String rootElementName)
Constructor for the SchemaHelper object for disk-based schema |
|
SchemaHelper(URL schemaURL)
Constructor for the SchemaHelper object |
|
SchemaHelper(URL schemaURL,
String rootElementName)
Constructor for the SchemaHelper object using web-based schema. |
Method Summary | |
---|---|
static void |
box(String s,
String prefix)
NOT YET DOCUMENTED |
boolean |
checkValidValue(String typeName,
String value)
Checks to see if a value is valid against a specified datatype. |
String |
decodeAnyTypeXpath(String xpath)
Replaces xpath used to access an "anyType" node in the XML Document with a version that is known to the schema. |
void |
destroy()
Description of the Method |
String |
encodeAnyTypeXpath(String xpath)
Replaces xpath having node name of "any" with a wild-card version that can actually access the any element (which is anonymous) in the XML Document. |
String |
encodePathIfAnyType(String xpath)
|
List |
getChildrenOrder(String xpath)
Returns a list of element names for the given path from the instanceDoc. |
Compositor |
getCompositor(SchemaNode schemaNode)
Gets the compositor attribute of the SchemaHelper object |
Compositor |
getCompositor(String xpath)
Gets the compositor attribute of the SchemaHelper object |
DefinitionMiner |
getDefinitionMiner()
Gets the definitionMiner attribute of the SchemaHelper object |
List |
getEnumerationValues(GlobalDef globalDef,
boolean getLeafValues)
Gets the enumerationValues that are specified by the typeName. |
List |
getEnumerationValues(String typeName,
boolean getLeafValues)
Gets the enumerationValues attribute of the SchemaHelper object |
GlobalDef |
getGlobalDef(SchemaNode schemaNode)
Gets a globalDef from the globalDefMap. |
GlobalDef |
getGlobalDef(String typeName)
Gets a globalDef from the default namespace of the globalDefMap. |
GlobalDef |
getGlobalDefFromXPath(String xpath)
Finds a globalDef object for a given xpath. |
GlobalDefMap |
getGlobalDefMap()
Gets the globalDefMap attribute of the SchemaHelper object. |
Node |
getInstanceDocNode(String xpath)
Gets a Node from the instanceDocument |
List |
getInstanceDocNodes(String xpath)
Gets the instanceDocNodes attribute of the SchemaHelper object |
Document |
getInstanceDocument()
Gets the instanceDocument attribute of the SchemaHelper object |
static int |
getMaxOccurs(Element e)
Utility to extract the maxOccurs attribute of the given element and returns an int equivalent. |
Document |
getMinimalDocument()
Create a miminal instance document that is used as the starting point for a new document. |
static int |
getMinOccurs(Element e)
Extract the minOccurs attribute of the given element and returns an int equivalent. |
boolean |
getNamespaceEnabled()
Gets the namespaceEnabled attribute of the SchemaHelper object |
Element |
getNewElement(String encodedPath)
Creates a "miminalElement" (one that contains only required elements) from the instanceDocument. |
SchemaNode |
getParentSchemaNode(SchemaNode schemaNode)
Gets the parent of a SchemaNode |
SchemaNode |
getParentSchemaNode(String xpath)
Gets the parent of the SchemaNode associated with a given xpath |
String |
getRepeatingComplexSingletonChildName(String xpath)
Gets the qualified element name of the repeatingComplexSingleton child of the node specified by the provided path, or an empty string if such a child does not exist. |
String |
getRootElementName()
Gets the rootElementName attribute of the SchemaHelper object |
String |
getSchemaLocation()
Gets the rootURI attribute of the SchemaHelper object |
Namespace |
getSchemaNamespace()
|
SchemaNode |
getSchemaNode(String xpath)
Gets a schemaNode from the schemaNodeMap. |
SchemaNodeMap |
getSchemaNodeMap()
Gets the schemaNodeMap attribute of the SchemaHelper object |
SchemaProps |
getSchemaProps()
Gets the schemaProps attribute of the SchemaHelper object |
String |
getTargetNamespace()
Gets the targetNamespace attribute of the SchemaHelper object |
String |
getVersion()
Gets the version attribute of the SchemaHelper object |
com.sun.msv.datatype.xsd.XSDatatype |
getXSDataType(String dataTypeName)
Get a named XSDatatype object used to validate input. |
XSDatatypeManager |
getXSDatatypeManager()
Gets the xsdDatatypeManager attribute of the SchemaHelper object. |
boolean |
hasChoiceCompositor(SchemaNode schemaNode)
Returns true if the Node's type definition specifies a choice compositor |
boolean |
hasChoiceCompositor(String encodedXPath)
NOT YET DOCUMENTED |
boolean |
hasCompositor(String encodedXPath)
Returns true if the schemaNode for the specified path has a compositor. |
boolean |
hasMultiSelect(SchemaNode schemaNode)
multiselect iff isComplex hasSequenceCompositor containing a single multiSelect element |
boolean |
hasOptionalMultiSelect(SchemaNode schemaNode)
Returns true if this element is optional and contains only a single multiSelect element. |
boolean |
hasOptionalMultiSelect(String pathArg)
Test a JSP-encoded pathArg for whether it refers to an element that satisfies the hasOptionalMultiSelect(SchemaNode) predicate. |
boolean |
hasRepeatingComplexSingleton(String xpath)
Returns true if the node at the provided path contains a Single, Complex element with maxOccurs of more than 1. |
boolean |
hasRequiredMultiSelect(SchemaNode schemaNode)
NOT YET DOCUMENTED |
boolean |
hasSequenceCompositor(SchemaNode schemaNode)
Returns true if the Node's type definition specifies a sequence compositor |
boolean |
hasSequenceCompositor(String encodedXPath)
NOT YET DOCUMENTED |
boolean |
isAnyTypeElement(String xpath)
|
boolean |
isChoiceElement(SchemaNode schemaNode)
Return true if this element is a member of a choice compositor. |
boolean |
isChoiceElement(String encodedXPath)
Gets the choiceElement attribute of the SchemaHelper object |
boolean |
isComboUnionType(GlobalDef typeDef)
Gets the comboUnionType attribute of the SchemaHelper object |
boolean |
isEnumerationType(GlobalDef typeDef)
Returns true if the given typeDef represents an eumeration datatype |
boolean |
isEnumerationType(String typeName)
Returns true if the typeName corresponds to datatype that represents an enumeration. |
boolean |
isMultiChoiceElement(SchemaNode schemaNode)
Returns true if the given schemaNode allows for multiple choice children elements. |
boolean |
isMultiChoiceElement(String encodedXPath)
Returns true if the given path corresponds to a schemaNode that allows for multiple choice children elements. |
boolean |
isMultiSelect(SchemaNode schemaNode)
Determines if the SchemaNode should rendered as a MultiSelect Element (e.g., checkboxes). |
boolean |
isMultiSelect(String encodedXPath)
Gets the multiSelect attribute of the SchemaHelper object |
boolean |
isRecursiveElement(String encodedXPath)
|
boolean |
isRepeatingComplexSingleton(String xpath)
Returns true if the provided path meets the requirememts for a repeating complex singleton element. |
boolean |
isRepeatingElement(SchemaNode schemaNode)
Gets the repeatingElement attribute of the SchemaHelper object |
boolean |
isRepeatingElement(SchemaNode schemaNode,
GlobalDef typeDef)
Determines whether an instanceDocumentNode is a repeating element (i.e., it has maxOccurs > 1 and is NOT an enumerationType). |
boolean |
isRepeatingElement(String encodedXPath)
Gets the repeatingElement attribute of the SchemaHelper object |
boolean |
isRequiredAttribute(SchemaNode schemaNode)
Returns true if a SchemaNode defines a
required attribute. |
boolean |
isRequiredBranch(SchemaNode schemaNode)
Returns true if the schemaNode is an element, a complexType (a branch) and is required. |
boolean |
isRequiredContentElement(SchemaNode schemaNode)
Returns true if the given schemaNode must have a text value (in addition to possibly having subelements). |
boolean |
isSingleton(SchemaNode schemaNode)
Returns true if this schemaNode is the only child of it's parent. |
boolean |
isSingleton(String xpath)
Gets the singleton attribute of the SchemaHelper object |
static void |
main(String[] args)
The main program for the SchemaHelper class |
static void |
setDebug(boolean d)
Sets the debug attribute of the SchemaHelper class |
void |
setSchemaNodeReadOnly(String xpath)
set the isReadOnly attribute of the schemaNode specified by the given xpath to true |
static void |
setVerbose(boolean v)
Sets the verbose attribute of the SchemaHelper class |
static String |
toSchemaPath(String encodedXPath)
convert a jsp-encoded path into a normalized form for accessing schemaNodes |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MINOCCURS_DEFAULT
public static final int MAXOCCURS_DEFAULT
public static final String NILLABLE_DEFAULT
public static final int UNBOUNDED
Constructor Detail |
---|
public SchemaHelper(File schemaFile) throws SchemaHelperException
schemaFile
- NOT YET DOCUMENTED
SchemaHelperException
- NOT YET DOCUMENTEDpublic SchemaHelper(File schemaFile, String rootElementName) throws SchemaHelperException
schemaFile
- path to root file of schemarootElementName
- NOT YET DOCUMENTED
SchemaHelperException
- Description of the Exceptionpublic SchemaHelper(URL schemaURL) throws SchemaHelperException
schemaURL
- NOT YET DOCUMENTED
SchemaHelperException
- NOT YET DOCUMENTEDpublic SchemaHelper(URL schemaURL, String rootElementName) throws SchemaHelperException
schemaURL
- URL to root file of schemarootElementName
- NOT YET DOCUMENTED
SchemaHelperException
- Description of the ExceptionMethod Detail |
---|
public boolean getNamespaceEnabled()
public SchemaProps getSchemaProps()
public String getSchemaLocation()
public Namespace getSchemaNamespace()
public String getVersion()
public String getRootElementName()
public String getTargetNamespace()
public GlobalDef getGlobalDef(String typeName)
typeName
- the name of the globalDef object
GlobalDef
object, or null if not found.public GlobalDef getGlobalDef(SchemaNode schemaNode)
schemaNode
- a SchemaNode
object
GlobalDef
object, or
null if not found.public Compositor getCompositor(String xpath)
xpath
- NOT YET DOCUMENTED
public Compositor getCompositor(SchemaNode schemaNode)
schemaNode
- NOT YET DOCUMENTED
public Node getInstanceDocNode(String xpath)
Node
from the instanceDocument
xpath
- xpath specifying the desired node
public List getInstanceDocNodes(String xpath)
xpath
- NOT YET DOCUMENTED
public SchemaNode getSchemaNode(String xpath)
xpath
- A string representation of an XPath
SchemaNode
object , or null if not foundpublic void setSchemaNodeReadOnly(String xpath)
xpath
- The new schemaNodeReadOnly valuepublic SchemaNode getParentSchemaNode(String xpath)
xpath
- A string representation of an XPath
public SchemaNode getParentSchemaNode(SchemaNode schemaNode)
schemaNode
- a SchemaNode
public static void main(String[] args)
args
- The command line argumentspublic com.sun.msv.datatype.xsd.XSDatatype getXSDataType(String dataTypeName)
XSDatatype
object used to validate input. Used only by
EditorAction in the "suggest" package org.dlese.dpc.to validate the email
field. this is necessary because the email field is not really specified as
being of this type and therefore another way is necessary for finding a
validating type.
dataTypeName
- The name of a XSDatatype
object
public XSDatatypeManager getXSDatatypeManager()
public GlobalDefMap getGlobalDefMap()
public Document getInstanceDocument()
public DefinitionMiner getDefinitionMiner()
public boolean checkValidValue(String typeName, String value) throws Exception
value
- Value to be validatedtypeName
- Name of the DataType to be validated against
Exception
- If the value is not valid. The exception usually
contains helpful informationpublic SchemaNodeMap getSchemaNodeMap()
public static String toSchemaPath(String encodedXPath)
encodedXPath
- Description of the Parameter
public boolean isRepeatingElement(String encodedXPath)
encodedXPath
- Description of the Parameter
public boolean isRepeatingElement(SchemaNode schemaNode)
schemaNode
- Description of the Parameter
public boolean isRepeatingElement(SchemaNode schemaNode, GlobalDef typeDef)
schemaNode
- a wrapper to a Node in the instanceDocumenttypeDef
- a DataType to be tested for isEumeration
public boolean isRecursiveElement(String encodedXPath)
public boolean isSingleton(String xpath)
xpath
- NOT YET DOCUMENTED
public boolean isSingleton(SchemaNode schemaNode)
schemaNode
- NOT YET DOCUMENTED
public boolean isRepeatingComplexSingleton(String xpath)
xpath
- NOT YET DOCUMENTED
public boolean hasRepeatingComplexSingleton(String xpath)
xpath
- NOT YET DOCUMENTED
public String getRepeatingComplexSingletonChildName(String xpath)
xpath
- NOT YET DOCUMENTED
public boolean isAnyTypeElement(String xpath)
public boolean isMultiChoiceElement(String encodedXPath)
encodedXPath
- xpath corresponding to a schemaNode to be tested
public boolean isMultiChoiceElement(SchemaNode schemaNode)
schemaNode
- schemaNode to be tested
public boolean isChoiceElement(String encodedXPath)
encodedXPath
- NOT YET DOCUMENTED
public boolean isChoiceElement(SchemaNode schemaNode)
This is determined by the typeDefinition of the element's parent.
schemaNode
- Description of the Parameter
public boolean hasChoiceCompositor(String encodedXPath)
encodedXPath
- NOT YET DOCUMENTED
public boolean hasCompositor(String encodedXPath)
encodedXPath
- NOT YET DOCUMENTED
public boolean hasChoiceCompositor(SchemaNode schemaNode)
schemaNode
- Description of the Parameter
public boolean hasSequenceCompositor(String encodedXPath)
encodedXPath
- NOT YET DOCUMENTED
public boolean hasSequenceCompositor(SchemaNode schemaNode)
schemaNode
- Description of the Parameter
public boolean isMultiSelect(String encodedXPath)
encodedXPath
- Description of the Parameter
public boolean isMultiSelect(SchemaNode schemaNode)
schemaNode
- Description of the Parameter
public boolean hasMultiSelect(SchemaNode schemaNode)
schemaNode
- NOT YET DOCUMENTED
public boolean hasOptionalMultiSelect(String pathArg)
hasOptionalMultiSelect(SchemaNode)
predicate.NOTE: NEVER REFERENCED
pathArg
- an JSP-encoded XPath
public boolean hasOptionalMultiSelect(SchemaNode schemaNode)
schemaNode
- Description of the Parameter
public boolean hasRequiredMultiSelect(SchemaNode schemaNode)
schemaNode
- NOT YET DOCUMENTED
public boolean isRequiredBranch(SchemaNode schemaNode)
schemaNode
- Description of the Parameter
public boolean isRequiredContentElement(SchemaNode schemaNode)
NOTE: currently we are calling ANY extended element (besides stringTextType) optional. I don't even know how you would define it as required in the schema, but I'm not worrying about it for now ...
schemaNode
- Description of the Parameter
public boolean isRequiredAttribute(SchemaNode schemaNode)
SchemaNode
defines a
required attribute.
schemaNode
- Description of the Parameter
public boolean isComboUnionType(GlobalDef typeDef)
typeDef
- NOT YET DOCUMENTED
public boolean isEnumerationType(GlobalDef typeDef)
typeDef
- Description of the Parameter
public boolean isEnumerationType(String typeName)
typeName
- the name of a datatype defined by a schema
public List getChildrenOrder(String xpath)
xpath
- NOT YET DOCUMENTED
public List getEnumerationValues(GlobalDef globalDef, boolean getLeafValues)
getLeafValues
- specifies whether human-readable values are returnedglobalDef
- NOT YET DOCUMENTED
public List getEnumerationValues(String typeName, boolean getLeafValues)
typeName
- NOT YET DOCUMENTEDgetLeafValues
- NOT YET DOCUMENTED
public GlobalDef getGlobalDefFromXPath(String xpath)
SchemaNodeMap
and then using the name as an index into the GlobalDefMap
.
xpath
- an xpath to a specific node
GlobalDef
objectpublic Document getMinimalDocument()
Document
public Element getNewElement(String encodedPath)
encodedPath
- JSP-encoded xpath that specifies the element to create
public static int getMaxOccurs(Element e)
e
- element from a xml schema
public static int getMinOccurs(Element e)
e
- element from a xml schema
public String encodePathIfAnyType(String xpath)
public String encodeAnyTypeXpath(String xpath)
public String decodeAnyTypeXpath(String xpath)
public void destroy()
public static void setDebug(boolean d)
d
- The new debug valuepublic static void setVerbose(boolean v)
v
- The new verbose valuepublic static void box(String s, String prefix)
s
- NOT YET DOCUMENTEDprefix
- NOT YET DOCUMENTED
|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |