Package schema2template.grammar
Class XMLModel
java.lang.Object
schema2template.grammar.XMLModel
The most important model, the first access to the XML Schema information.
Provides all XML attribute and XML element definitions from the schema. All further information can be accessed from those definitions (e.g. dependencies, constant values, data types, etc.).
-
Field Summary
Modifier and TypeFieldDescriptioncom.sun.msv.grammar.Expression
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Convert a-few:words into AFewWords in CamelCase spellingstatic String
camelCase
(PuzzleComponent def) Convert a-few:words into AFewWords in CamelCase spellingstatic String
constantCase
(String raw) Convert a-few:words into A_FEW_WORDS in spelling used for Java constantsstatic String
Convert a-few:words into A_FEW_WORDS in spelling used for Java constantsstatic String
escapeKeyword
(String in) (Java) Keyword may not start with a number, so escape itstatic String
(Java) member variable may not start with a number, so escape itstatic String
escapeLiteral
(String in) Escape the quotation marks of String literalsstatic String
Escape the quotation marks of String literalsstatic String
extractLocalName
(String name) Extract localname local from ns:local namestatic String
Extract localname local from ns:local namestatic String
extractNamespacePrefix
(String name) Extract namespace ns from ns:local namestatic String
Extract namespace ns from ns:local namestatic String
Assist method for camel-case adaptions or namespace extraction.static String
firstWord
(PuzzleComponent def) Maybe not used anymore: Get first word out of a PuzzleComponent object containing delimiters like "-:/ _.,"getAttribute
(String name) Get attribute by tag name.getAttribute
(String name, int hashCode) Get attribute by tag name and hash code.Get all attributes, sorted by ns:local name.getAttributes
(String qName) getElement
(String name) Get element(s) by tag name.getElement
(String name, int hashCode) Get element by tag name and hash code.Get all elements, sorted by ns:local name.getElements
(String qName) com.sun.msv.grammar.Grammar
static String
Convert a-few:words into aFewWords in spelling for java method namesstatic String
javaCase
(PuzzleComponent def) Convert a-few:words into aFewWords in spelling for java method namesstatic String
Maybe not used anymore: Get last word out of a String containing delimiters like "-:/ _.,"static String
lastWord
(PuzzleComponent def) Maybe not used anymore: Get last word out of a String containing delimiters like "-:/ _.,"static com.sun.msv.grammar.Grammar
loadSchema
(File rngFile) Load and parse a Schema from File.static com.sun.msv.grammar.Grammar
loadSchema
(String rngFilePath) Load and parse a Schema from File.static void
writeGrammar
(com.sun.msv.grammar.Grammar g, OutputStream out) Writes a grammar to the specified output.
-
Field Details
-
mRootExpression
public com.sun.msv.grammar.Expression mRootExpression -
mLastSchemaFileName
-
-
Constructor Details
-
XMLModel
Constructs new model by the grammar and a label- Parameters:
schemaFile
- grammar to read into MSV
-
XMLModel
Constructs new model by the grammar and a label- Parameters:
schemaFile
- grammar to read into MSVgrammarVersion
- numbered version used to establish timely order and create a label with the grammarIDgrammarID
- identifier of the grammar (used in Velocity template and for output subdirectories - often concatenated with grammarVersion)
-
-
Method Details
-
getElements
- Returns:
- a set of one or more elements, which might exist in the grammar for this qName
-
getAttributes
- Returns:
- a set of one or more elements, which might exist in the grammar for this qName
-
getGrammar
public com.sun.msv.grammar.Grammar getGrammar()- Returns:
- the MSV Grammar this model is based upon.
-
getGrammarVersion
- Returns:
- the version label identifying this version of this schema (XML grammar)
-
getGrammarID
- Returns:
- the grammar ID identifying this schema (XML grammar)
-
loadSchema
Load and parse a Schema from File.- Parameters:
rngFile
- Schema file (RelaxNG or W3C schema)- Returns:
- MSV Expression Tree (more specific: The tree's MSV root expression)
-
loadSchema
Load and parse a Schema from File.- Parameters:
rngFilePath
- Schema file (RelaxNG or W3C schema)- Returns:
- MSV Expression Tree (more specific: The tree's MSV root expression)
-
writeGrammar
public static void writeGrammar(com.sun.msv.grammar.Grammar g, OutputStream out) throws SAXException Writes a grammar to the specified output.- Throws:
SAXException
-
getElements
Get all elements, sorted by ns:local name.- Returns:
- Unmodifiable SortedSet of elements
-
getAttributes
Get all attributes, sorted by ns:local name.- Returns:
- Unmodifiable SortedSet of attributes
-
getElement
Get element(s) by tag name. If there are multiple elements sharing the same tag name, a PuzzlePieceSet is returned. If not, a single PuzzlePiece is returned.- Parameters:
name
-- Returns:
- Element PuzzlePiece(s)
-
getElement
Get element by tag name and hash code. The hash code distincts elements from sharing the same tag name.- Parameters:
name
-hashCode
-- Returns:
- Element PuzzlePiece
-
getAttribute
Get attribute by tag name. If there are multiple attributes sharing the same tag name, a PuzzlePieceSet is returned. If not, a single PuzzlePiece is returned.- Parameters:
name
-- Returns:
- Attribute PuzzlePiece(s)
-
getAttribute
Get attribute by tag name and hash code. The hash code distincts Attributes sharing the same tag name.- Parameters:
name
-hashCode
-- Returns:
- Attribute PuzzlePiece
-
camelCase
Convert a-few:words into AFewWords in CamelCase spelling- Parameters:
raw
- input String- Returns:
- filtered output String
-
camelCase
Convert a-few:words into AFewWords in CamelCase spelling- Parameters:
def
- input- Returns:
- filtered output String
-
javaCase
Convert a-few:words into aFewWords in spelling for java method names- Parameters:
raw
- input String- Returns:
- filtered output String
-
javaCase
Convert a-few:words into aFewWords in spelling for java method names- Parameters:
def
- input- Returns:
- filtered output String
-
constantCase
Convert a-few:words into A_FEW_WORDS in spelling used for Java constants- Parameters:
raw
- input String- Returns:
- filtered output String
-
constantCase
Convert a-few:words into A_FEW_WORDS in spelling used for Java constants- Parameters:
def
- input- Returns:
- filtered output String
-
firstWord
Assist method for camel-case adaptions or namespace extraction. Maybe not used anymore: Get first word out of a String containing delimiters like "-:/ _.,"- Parameters:
raw
- input String- Returns:
- filtered output String
-
firstWord
Maybe not used anymore: Get first word out of a PuzzleComponent object containing delimiters like "-:/ _.,"- Parameters:
def
- input- Returns:
- first word
-
lastWord
Maybe not used anymore: Get last word out of a String containing delimiters like "-:/ _.,"- Parameters:
raw
- input- Returns:
- last word
-
lastWord
Maybe not used anymore: Get last word out of a String containing delimiters like "-:/ _.,"- Parameters:
def
- input- Returns:
- last word
-
escapeKeyword
(Java) member variable may not start with a number, so escape it- Parameters:
in
- raw input- Returns:
- filtered output, starting with a literal
-
escapeKeyword
(Java) Keyword may not start with a number, so escape it- Parameters:
in
- raw input- Returns:
- filtered output, starting with a literal
-
escapeLiteral
Escape the quotation marks of String literals- Parameters:
in
- raw input- Returns:
- filtered output, with escaped quotation marks
-
escapeLiteral
Escape the quotation marks of String literals- Parameters:
in
- raw input- Returns:
- filtered output, with escaped quotation marks
-
extractNamespacePrefix
Extract namespace ns from ns:local name- Parameters:
name
- in form ns:local- Returns:
- ns part from ns:local name
-
extractNamespacePrefix
Extract namespace ns from ns:local name- Parameters:
def
- PuzzleComponent object- Returns:
- ns part from ns:local name
-
extractLocalName
Extract localname local from ns:local name- Parameters:
name
- in form ns:local- Returns:
- local part from ns:local name
-
extractLocalName
Extract localname local from ns:local name- Parameters:
def
- PuzzleComponent object- Returns:
- local part from ns:local name
-