public class SchemaRep extends Object implements PrefixGuesser
| Modifier and Type | Field and Description |
|---|---|
protected Stack |
currentElementStack |
static boolean |
debug |
protected Map |
definedAttributes |
protected Map |
definedTypes |
protected Map |
definedTypesFull |
protected String |
documentNamespace |
protected Map |
elementTable |
protected Map |
includedAlready |
protected SchemaRep.ElementExpr |
lastPopped |
protected Map |
namespaceTable |
protected Map |
optionallyDefinedTypes |
protected Map |
predefinedSchemaTypes |
protected Map |
requiredPredefinedTypes |
protected SchemaRep.ContainsSubElements |
rootElement |
protected Map |
sampleNodes |
protected String |
targetNamespace |
protected SchemaRep.Annotation |
topAnnotation |
static String |
XSD_NS |
| Constructor and Description |
|---|
SchemaRep() |
SchemaRep(Document schemaDoc,
String uri) |
SchemaRep(Document schemaDoc,
String uri,
boolean useBigDataTypes) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAppInfo(String name,
String value)
Create AppInfo and add it to the current thing in the stack.
|
void |
addAppInfoToTopAnnotation(String name,
String value) |
void |
addElement(String name,
String type)
Create an Element an add it to the current one in the stack.
|
protected void |
addRestriction(SchemaRep.ContainsSubElements cse,
String restrictionBase,
SchemaRep.RestrictionType... rt) |
void |
addSubElement(String elementName,
List subElements) |
void |
addSubElement(String elementName,
SchemaRep.ElementExpr subElement) |
void |
addSubElement(String elementName,
String subElementName) |
void |
addSubElementCurrent(String subElementName)
This addSubElement creates an Element and then adds it underneath
the current one.
|
void |
addToNamespace(String ns,
String URI)
Example: ns=xsd, URI=http://www.w3.org/2001/XMLSchema
|
void |
addToTopAnnotation(SchemaRep.ElementExpr subElement) |
static String |
canonicalQName(String namespaceURI,
String localPart) |
SchemaRep.Element |
createElement(String name)
Return an Element that represents an ELEMENT.
|
SchemaRep.Element |
createElement(String name,
String type)
Return an Element that represents an ELEMENT.
|
List |
findAllSubElements(String name) |
Set |
getAllNamespaces() |
SchemaRep.Attribute |
getAttribute(String name) |
protected String |
getCurrentParsedURI() |
SchemaRep.Element |
getDefinedElement(String typeName) |
Set |
getDefinedElementNames() |
SchemaRep.Element |
getDefinedElementResolvedNamespace(String typeName) |
SchemaRep.ElementExpr |
getLastPopped() |
String |
getNamespace(String URI)
Return a namespace name for a given namespace URI.
|
String |
getNamespaceURI(String ns)
Return the namespace URI for a given namespace prefix.
|
SchemaRep.ContainsSubElements |
getRootElement() |
protected SchemaRep.ElementExpr |
getSampleNode(String name) |
SchemaRep.ElementExpr |
getSchemaTypeDef(String origTypeName)
Get an ElementExpr node for a named type.
|
SchemaRep.ElementExpr |
getSchemaTypeDefResolvedNamespace(String typeName)
Same thing as getSchemaTypeDef, but for already resolved type names.
|
Set |
getSchemaTypeNames() |
String |
getTargetNamespace() |
String |
getXMLNamespace() |
static String |
getXPathExpr(Node node) |
static String |
getXPathExpr(Node node,
boolean addDescription) |
String |
getXSDNamespace() |
static String |
guessPrefix(String namespaceURI)
Guess what a prefix of this namespaceURI might be.
|
String |
guessPrefixFromURI(String uri)
Try to figure out what prefix to use for the namespaceURI
using the namespace context mapping, and if that fails then it
calls guessPrefix.
|
boolean |
isDefinedType(String type) |
boolean |
isPredefinedType(String type) |
String |
javaType2XMLSchemaTypeComplex(String type) |
void |
mapSimpleJavaTypesOptional(Map optionalElementMap)
Map simple types to our schema.
|
void |
mapSimpleJavaTypesPredefined(Map definedElementMap)
Map simple types to our schema.
|
protected String |
normalizeDocumentNamespace(String type) |
protected String |
normalizeNamespace(String namespaceURI,
String localPart)
return prefix ':' localPart
eg: namespaceURI="http://www.w3.org/XML/1998/namespace" localPart="id" -> "xml:id"
eg: namespaceURI="" localPart="foo" -> "foo"
eg: namespaceURI=null localPart="bar" -> "bar"
|
protected String |
normalizeTargetNamespace(String type)
Will add a namespace prefix to a type if the targetNamespace != null.
|
SchemaRep.ElementExpr |
optimize()
This is called before writing out a schema.
|
SchemaRep.ElementExpr |
peekCurrent() |
SchemaRep.ContainsSubElements |
peekCurrentNeedSub()
Same thing as peekCurrent, but the caller needs it to be a
ContainsSubElements.
|
SchemaRep.ElementExpr |
popCurrent() |
static String |
prefixOf(String typeName)
eg: 'xsd:element' -> 'xsd'
|
static void |
printExtraJavaTypes(Writer out,
int level)
Define some helpful java to XML Schema data types that allow us
to go back and forth between the two (allows me to setup a 1-to-1
mapping with the client proxy generator).
|
void |
pushComplexType() |
void |
pushCurrent(SchemaRep.ElementExpr el) |
void |
pushElement(String elementName,
String elementType)
Create the element, then push it onto the stack, making it the
current one.
|
void |
pushSchemaNode() |
void |
pushSequence() |
protected void |
putSampleNode(SchemaRep.ElementExpr ee) |
void |
putSchemaTypeDef(String typeName,
SchemaRep.ElementExpr ee) |
protected void |
read(Node node) |
void |
readDocument(Document doc) |
void |
readSchemaElement(Element el,
boolean include) |
void |
readSchemaFromLocation(String schemaLocation,
boolean include) |
static String |
removePrefix(String typeName) |
String |
resolveNamespace(String typeName)
Will convert a typeName into {namespace}typeName format.
|
String |
resolveNamespace(String ns,
String type) |
protected String |
resolveNamespaceDefault(String typeName,
String defaultNS) |
protected String |
resolveNamespaceDefault(String prefix,
String defaultNS,
String type) |
String |
schemaTypeToJavaType(String xmlSchemaType) |
void |
setCurrentParsedURI(String uri) |
void |
setMaxOccurs(String t)
Only works if the current thing in the stack is an Element or ModelGroup.
|
void |
setMinOccurs(String t)
Only works if the current thing in the stack is an Element or ModelGroup.
|
void |
setRootElement(SchemaRep.ContainsSubElements el) |
void |
setSchemaTypeMapping(String schemaTypeNamespace,
String schemaTypeName,
String javaType) |
void |
setSchemaTypesForME(boolean isFloatingPoint)
Setup the schema to java type mapping to make more sense for J2ME.
|
void |
setTargetNamespace(String ns) |
void |
setType(String t)
Only works if the current thing in the stack is an Element.
|
void |
setXMLSchemaType(String t)
Only works if the current thing in the stack is an Element.
|
void |
writeDTD(Writer out)
If you want a DTD written to a Writer, this is the method
to call.
|
void |
writeXMLSchema(XMLWriter out) |
void |
writeXMLSchemaStandalone(Writer out)
If you want an XML Schema written to a Writer, this is the method
to call.
|
public static boolean debug
public static final String XSD_NS
protected Map namespaceTable
protected String targetNamespace
protected String documentNamespace
protected SchemaRep.ContainsSubElements rootElement
protected Map elementTable
protected Map optionallyDefinedTypes
protected Map definedTypes
protected Map definedTypesFull
protected Map definedAttributes
protected Map predefinedSchemaTypes
protected Map requiredPredefinedTypes
protected Stack currentElementStack
protected SchemaRep.Annotation topAnnotation
protected SchemaRep.ElementExpr lastPopped
protected Map sampleNodes
protected Map includedAlready
public void addToNamespace(String ns, String URI)
public String getNamespaceURI(String ns)
public String getNamespace(String URI)
public Set getAllNamespaces()
public String getXSDNamespace()
public String getXMLNamespace()
public SchemaRep.Attribute getAttribute(String name)
protected void putSampleNode(SchemaRep.ElementExpr ee)
protected SchemaRep.ElementExpr getSampleNode(String name)
public void setTargetNamespace(String ns)
public String getTargetNamespace()
public void setCurrentParsedURI(String uri)
protected String getCurrentParsedURI()
public void setRootElement(SchemaRep.ContainsSubElements el)
public SchemaRep.ContainsSubElements getRootElement()
public void addToTopAnnotation(SchemaRep.ElementExpr subElement)
public void pushCurrent(SchemaRep.ElementExpr el)
public void pushElement(String elementName, String elementType)
public void pushSchemaNode()
public void pushComplexType()
public void pushSequence()
public SchemaRep.ElementExpr popCurrent()
public SchemaRep.ElementExpr peekCurrent()
public SchemaRep.ContainsSubElements peekCurrentNeedSub()
public SchemaRep.ElementExpr getLastPopped()
public void addElement(String name, String type)
public void addAppInfo(String name, String value)
public void setType(String t)
public void setXMLSchemaType(String t)
public void setMinOccurs(String t)
public void setMaxOccurs(String t)
public SchemaRep.Element createElement(String name)
public SchemaRep.Element createElement(String name, String type)
public void addSubElement(String elementName, SchemaRep.ElementExpr subElement)
public void addSubElementCurrent(String subElementName)
public SchemaRep.ElementExpr optimize()
public void writeDTD(Writer out) throws IOException
IOExceptionpublic void writeXMLSchemaStandalone(Writer out) throws IOException
IOExceptionpublic void writeXMLSchema(XMLWriter out) throws IOException
IOExceptionpublic void readSchemaFromLocation(String schemaLocation, boolean include) throws IOException, SAXException
IOExceptionSAXExceptionpublic void readDocument(Document doc)
public void readSchemaElement(Element el, boolean include)
protected void read(Node node)
public SchemaRep.ElementExpr getSchemaTypeDef(String origTypeName)
public SchemaRep.ElementExpr getSchemaTypeDefResolvedNamespace(String typeName)
public Set getSchemaTypeNames()
public SchemaRep.Element getDefinedElement(String typeName)
public SchemaRep.Element getDefinedElementResolvedNamespace(String typeName)
typeName - is the resolved type name "{http://foo}login"public Set getDefinedElementNames()
public void putSchemaTypeDef(String typeName, SchemaRep.ElementExpr ee)
public String resolveNamespace(String typeName)
protected String resolveNamespaceDefault(String prefix, String defaultNS, String type)
protected String normalizeTargetNamespace(String type)
protected String normalizeNamespace(String namespaceURI, String localPart)
public void setSchemaTypeMapping(String schemaTypeNamespace, String schemaTypeName, String javaType)
schemaTypeName - The name of a leaf schema element, like 'integer'.javaType - The java class schemaTypeName gets mapped to, like 'int'.public void setSchemaTypesForME(boolean isFloatingPoint)
protected void addRestriction(SchemaRep.ContainsSubElements cse, String restrictionBase, SchemaRep.RestrictionType... rt)
public void mapSimpleJavaTypesOptional(Map optionalElementMap)
public void mapSimpleJavaTypesPredefined(Map definedElementMap)
public static void printExtraJavaTypes(Writer out, int level) throws IOException
IOExceptionpublic boolean isDefinedType(String type)
public boolean isPredefinedType(String type)
public static String guessPrefix(String namespaceURI)
public String guessPrefixFromURI(String uri)
guessPrefixFromURI in interface PrefixGuesserCopyright © 2017–2019 Eclipse Foundation. All rights reserved.